I am thinking of using an output pin of one process to signal another process to do something via it's input pin. I plan on using the attachinterrupt mechanism but am wondering why there is no software equivalent to what I want. Something like signal_interupt(interrupt#) would be nice, I know I can just hit a pin that is configured for an ISR but that still uses up pins, I was hoping to NOT use additional pins, sort of a software pin maybe. So far my research has not found anything but maybe I am not using the right word(s)
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
I am thinking of using an output pin of one process to signal another process to do something via it's input pin.
Could you please clarify what you mean in a bit more detail. I find the word process ambiguous since I can read it as "one processor" and "another processor" or one sketch vs another sketch.
But neither of these make sense because either case would just need direct connexion of the relevant pins and if it were a single processor, then no physical connexion at all would be required.
Anything seems possible when you don't know what you're talking about.
@will Keep in mind I am still in the analysis/design stage. By process I mean a logical self contained collection of code. On an arduino type board in this case an ESP32 all the processes are in a single sketch since I don't know if multiple sketches can be loaded on a board. I assume a single sketch/file can have multiple discreet procedures since the arduino cloud creates those kinds of sketches. What I am trying to do is pass execution from the main loop to one of those procedures such as (from my cloud generated sketch) onTimerKChange(). Is that clear?
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@zander Hi Ron,
Sorry, I am not quite clear what you are trying to do. I may have misunderstood your intention, but here is my attempt at addressing your question.
-------
Are you referring to 'software interrupts'?
... some (most?) processors have a vector table, in which each entry points to an interrupt handling subroutine for that particular interrupt event/cause.
Some processors have a software (assembly level) instruction which can call these interrupt handler subroutines, and have an extended vector table that includes entries which are not associated with a hardware event.
A quick Google suggested the Atmel processors used in most Arduinos do not include 'spare' vector table entries, although three pin entries were mentioned that could be used 'borrowed' to act as software interrupts if those pins were configured as outputs (which do not create interrupts).
The corresponding question is why are software interrupts needed or ' good idea'? In the 8080/Z80/8086 era they were often used as an 'interface' so each vector would be associated with a particular task, e.g. write a character to the screen. The IBM PC 'Bios' was a well-known example of this approach. However, whilst it provides a neat 'dispatch desk' model, the same actions can be performed using standard call subroutine code. For computers with only a few kilobytes of memory, it provides a means of reducing the length of a 'call' instruction, but that is less likely to be an issue now.
-----
Best wishes, Dave
Actually, that sounds more like a perfect example for implementation using Bill's last video on ESPs connected via an ESP-NOW Network.
Anything seems possible when you don't know what you're talking about.
@davee Thanks Dave, I understand all that, I am just dividing the tasks up into small chunks and was wondering if it's possible to treat them as interrupts as opposed to subroutines. It's not a big deal one way or the other, my problem is perhaps being overeducated. I was an IBM software CE and was very familiar with the guts of the mainframe OS's plus I learned on my own the PC end of the business. I then learned a multics variant called Stratus.
The reason I posted is that I see the arduino cloud generates sketches like I described, and am wondering how they are doing it. I have had a look at ISR stuff both in the ref man as well as the ESP hdwe docs. I also took a quick look at the tasking support in the ESP docs. what all that tells me is this should be doable, so my question wqs posed to ferret out somebody who has done it at a higher level as I don't need to get down in the weeds for performance reasons and can take a hit performance wise by using higher level api calls. Here is a sample cloud generated piece of code. This is the last few lines in the generated sketch. I did NOT write any of this.
/*
Since PbRemote is READ_WRITE variable, onPbRemoteChange() is
executed every time a new value is received from IoT Cloud.
*/
void onPbRemoteChange() {
// Add your code here to act upon PbRemote change
}
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@will I must have explained poorly. This is all on one board, and ESP32 with a bunch of GPIO pins. There will be 9 leds, 3 push buttons, an ssr, a couple of relay contacts used as signals for external AC power events, and all connected to my iPhone. No need for ESP-NOW, only one ESP board.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@zander Hi Ron,
Having seen your reply to @will, it sounds like you are heading to a multi-tasking system of some sort ... obviously there are various RTOS (Real-time operating systems) around, which are designed to enable different tasks to live in 'semi-isolated' worlds. The extent to which the tasks are allowed to interact and interfere with each other depending on the circumstances.
However, IDEs like Arduino are based on a 'simple' model and to my limited knowledge, do not appear conducive to this approach. They appear to have a simple view, that the processor has one program, consisting of a setup phase, followed by an endless loop. In many cases, it works well, but it is not a universal solution.
Obviously, you can use write two or more 'blobs' of code, each 'blob' doing its own task, and then perform some 'wizardry' to make them run in the same single overall program that could use the Arduino IDE, but it would be down to you make everything 'compatible and friendly'.
Best wishes, Dave
This is all on one board, and ESP32 with a bunch of GPIO pins.
The I would think that unless you want some massively complicated way of isolating the executable fragments that you're better off with subs and functions. I don't think either the ESP not the Arduino has such a framework available.
(Note, I'm less familiar with the ESP so take that pronouncement with a kilogram of salt)
Anything seems possible when you don't know what you're talking about.
@davee There is support in the arduino IDE for interrupt service routines and all that it encompasses. In order to get down to hard core tasking, you do need to use the ESP32 API. I was thinking of just using a physical pin to pin method. I simply attach a piece of code like I posted as an ISR to a pin, then I invoke it by writing to the connected pin but that wastes a lot of pins so I was wondering if there was a software alternative. As I wrote this it occured to me maybe I can get away with one pin per pair of processes, one process only writes to it, nd the other listens. That cuts it in half. Still a software equivalent is preffered in this case. Anybody?
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@will Yes, I can easily make it work the 'traditional' way but I am genetically pre-disposed to not use cpu cycles endlessly looping, it comes from my work on the stock markets. We had to have super fast code so I am sort of pre-conditioned. HOWEVER, since no one has popped up yet with some sort of signal statement, I will go back to the usual. It is kind of interesting though that the arduino IOT cloud generates code with no visible way to execute the procedure I posted a couple posts back. How does that code execute?
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
Here is a sample cloud generated piece of code. This is the last few lines in the generated sketch. I did NOT write any of this.
/*
Since PbRemote is READ_WRITE variable, onPbRemoteChange() is
executed every time a new value is received from IoT Cloud.
*/
void onPbRemoteChange() {
// Add your code here to act upon PbRemote change
}
Using this approach, it would be possible to write a dispatch routine which registers and stores pointers to a set of handler routines. Each routine could be sent a struct (say) with the current system state and would behave in such manner as necessary to perform its duty and return the updated system state. The dispatcher would then interpret the new system tae and call the appropriate handler.
But why create the overhead of doing all that when a convenient control stream (i.e. loop()) is available to interpret the current state and then call the other routines directly (when needed) ?
Anything seems possible when you don't know what you're talking about.
It is kind of interesting though that the arduino IOT cloud generates code with no visible way to execute the procedure I posted a couple posts back. How does that code execute?
Probably by callbacks.
Anything seems possible when you don't know what you're talking about.
@will Have you seen
https://www.arduino.cc/reference/en/libraries/cooperative-multitasking/
and
https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/
I know there is a formal way to do what I want, but I was just looking for a simpler approach that admittedly will not have processor affiliation control, or true concurrency but makes for a intellectually more pleasing solution.
The arduino solution for me is only available on the Nano 33 IoT as I don't have any of the other boards. The ESP32 sample I posted above does not meet my requirements but does show it is likely possible if one gets in the weeds with the system API.
We had this sort of mechanism back in my IBM days in the 70's using PL1 so it's nothing new.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@will Like I said, that is built into the boards, and I also more or less said it's just me being picky. My most recent work experience involved high performance so looping code was never used, everything was task based.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.