5:13 pm
March 19, 2015
This topic is started to post example code.
The code posted here is not tested and has an AS-IS status.
Comments to make the code better or a suggestion on a different approach is always welcome, this is how we can learn from each other.
Thanks, John
Ps, please state versions used:
Compiler, Arduino, LabView, and target used
4:33 am
March 19, 2015
Timed interrupt feature inspired me to make a very small task manager.
The task example name is Interrupt_Timer_main.vi but because it needs several vi's, i've made a installer like vi.
The installer VI with a zipped project in a string control ,will ask u to select a folder to put the vi's inside.
It will start the UI and the example code of the interrupt routine with the tasks.
John
Compiler: 10.0.0.14, Arduino 1.6.3, LabView 14, Uno
8:21 am
March 19, 2015
8 Channels PWM example (Timed interrupt).
This example shows the use of timed interrupt to generate 8 PWM signals.
The frequency for this software PWM generation with 8 channels is ~200Hz
All PWM channels have the same phase and have a resolution of ~1% (range 1-99).
Compiler: 10.0.0.15, Arduino 1.6.3, LabView 14, Uno
8:05 pm
March 19, 2015
Hello!
I intended to create a continuous AI-daq using the timer interrupt. Therefore, there is a main.vi, which I download with the compiler on my UNO-board. In this VI a buffer is beeing sent to a COM-port. The timer is referenced on the GetAI.vi. In this VI the buffer is filled.
There is also the reciever.vi, which is getting data from the COM-port while running on the PC.
My problem is not the interrupt itself, but the communication between UNO-board and PC. There is nothing on the serial port! even if I place a dummy sign to be sent in the while loop.
Why?
Another question: could a forum be created especially for code-problems?
4:23 am
March 12, 2015
Hi there. There are a couple problems here. Mainly, you have setup a global U16 buffer of size 1024 and a constant on the main block diagram of another 1024 elements. Thats 4k of RAM right there and the UNO only has 2k! So you are killing your program for sure. The other issue is that the concatenate option of auto-indexed loops is not supported (its a little hard to find) but this is a known issue. I changed a few other things in your code to simplify things and it now works (with a very small buffer to test). I also slowed the interrupt down so that the samples can be read out of the buffer faster than they are getting loaded by the interrupt for testing purposes. I just used the Serial Monitor to verify the output.
Another thing to keep in mind is that you are running your timer interrupt at 1000us. As documented here and in the VI documentation an analog read takes about 100us. With the other array manipulation in the interrupt handler timing could be a concern. Youd have to run some benchmarking to make sure there is enough time in the interrupt to finish before the next one fires.
10:19 am
March 19, 2015
Steffan said
Hi there. There are a couple problems here. Mainly, you have setup a global U16 buffer of size 1024 and a constant on the main block diagram of another 1024 elements. Thats 4k of RAM right there and the UNO only has 2k! So you are killing your program for sure. The other issue is that the concatenate option of auto-indexed loops is not supported (its a little hard to find) but this is a known issue. I changed a few other things in your code to simplify things and it now works (with a very small buffer to test). I also slowed the interrupt down so that the samples can be read out of the buffer faster than they are getting loaded by the interrupt for testing purposes. I just used the Serial Monitor to verify the output.Another thing to keep in mind is that you are running your timer interrupt at 1000us. As documented here and in the VI documentation an analog read takes about 100us. With the other array manipulation in the interrupt handler timing could be a concern. Youd have to run some benchmarking to make sure there is enough time in the interrupt to finish before the next one fires.
Thank a lot Steffan, I will try it
9:03 pm
March 19, 2015
Steffan said
Hi there. There are a couple problems here. Mainly, you have setup a global U16 buffer of size 1024 and a constant on the main block diagram of another 1024 elements. Thats 4k of RAM right there and the UNO only has 2k! So you are killing your program for sure. The other issue is that the concatenate option of auto-indexed loops is not supported (its a little hard to find) but this is a known issue. I changed a few other things in your code to simplify things and it now works (with a very small buffer to test). I also slowed the interrupt down so that the samples can be read out of the buffer faster than they are getting loaded by the interrupt for testing purposes. I just used the Serial Monitor to verify the output.Another thing to keep in mind is that you are running your timer interrupt at 1000us. As documented here and in the VI documentation an analog read takes about 100us. With the other array manipulation in the interrupt handler timing could be a concern. Youd have to run some benchmarking to make sure there is enough time in the interrupt to finish before the next one fires.
Hello Stefan,
thanx again for your tips. I tried to do it like you advised (empty array in the global variable, initialization of 128[], instead of 1024[], work-around on tunneling and auto-indexing in the for-loop), but it's still not talking with me. Could you please attach your code, which worked?
How about a new topic like "best practices", where is described why the "usual" way of LV-programming is not working here. My "bad" code could be a topic there... I think it would be helpful for those of us, who are not coming from embedded programming, (like me: application development on OS)
3:08 pm
March 12, 2015
Sorry, for some reason the edited code did not get attached to my earlier post. I just added it there called "AI_modified.zip". It has a 128 byte buffer now and seems to work.
As far as best practices, have you taken a look at the user manual? There is an "Important Considerations" section that describes exactly what things to be aware of with these limited memory targets. In fact, in many places in the documentation it tells you to be aware of dynamic memory usage on small targets like the Uno with arrays and string usage. So please do read the documentation.
5:13 am
December 20, 2015
5
1 Guest(s)