I have got my RISC OS Pi reading an accellerometer and gyroscope and keypad and writing to an LCD via I2C. I have previously successfully PWMed the 2 DC motors on my robot under Linux but have yet to try it under RISC OS as I don't want it to leap off the table and smash to pieces on the floor.
I would now like to have a go at setting up a timer interrupt to run a test program that simulates balancing.
One of my current test programs displays the accellerometer readings on the LCD screen in a loop until the D button on the keypad is pressed. I would like to adapt it so that instead of looping it will be called every 10ms by RISC OS.
David S said:
You should be able to set up a timer inturupt to handle the 10ms task. Though you may have to directly set up the HW timer to handle 10ms as that is 10 times faster than the centasecond timer provided by RISC OS. Though once you have the timer set up for that, you can do everything else in a standard task, or a singletasking program if that is more appropriate,
Of couce the code that handles the 10ms timer will have to be quite fast to leave much time to do anything else.
Well, 1 centasecond is
10ms (I think?) and the RPi's I2C works at 400kHz, so I am hoping to have at least some of that 10ms left over for higher functioning. I think my simulated balancing test program will be quick as intially it needs only:
1) read a value from an area of memory available to other programs
2) get x-axis accerometer reading via I2C
3) get x-axis gyroscope reading via I2C
4) dispay these 3 values on the LCD via I2C
5) add these 3 values and write the result to an area of memory available to other programs
I am hoping that I will also be able to run another test program in the background that passes values to and from this smaller frequently called 'balancing simulator'. This background program would represent a more abstract control system that might be concerned with non time critical tasks such as mapping the environment and setting the robots course.
I am not sure how to do this but I think I need to use a SWI to set this up. My question is - which SWIs should I use?
Think I need a HAL_interrupt API
http://www.riscosopen.org/wiki/document ... HAL%20APIs
I think this one?
http://www.riscosopen.org/wiki/document ... imer%20API
Any help much apprecitaed!