In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Zoot wrote: [quote="Somebody"]BTW: I noticed that you let the ISR update servo pulses and encoder ticks. In similar applications, I use the port B edge-detection feature, and check for port B transitions in the mainline program loop as this is usually executed at a higher repeat rate than the ISR code.[/quote] I thought about this, but in this particular application I'm getting, for discussion's sake, 2-40 encoder ticks every50 ms -- pretty slow. Average speed is around 12 ticks per 50ms. The ISR will be running every 4 us. My rough estimate is that the mainline I2CSEND (as a master) could take from 1 - 2 ms (depending on how many bytes I choose to send and/or receive, and NOT including add'l overhead of ISRs that will surely be callled between instructions during mainline I2C transactions) so it would seem that my ISR will run much more often (more accurately, during mainline frames when I2C transactions and frame calculations are taking place). Additionally, my estimate is that some of the long division for my PID and odometry *could* take some hundreds of instruction cycles for each calculation -- and depending on what odometry and PID is really being calculated (if no distance has been traveled or velocity read is the same, obviously, PID and odometry do not need to be recalculated, saving some 1000s of looped instructions for divides, multiplies, etc). Add to that IREADS for sin/cosine lookups, setting up the TX buffer to respond to queries from the host, etc. and things add up a bit for the mainline. In short, I've been budgeting a 1ms-4ms time in the mainloop during frames execution (servos, PID, odometry) at 50mhz and upon updates from the host via serial RX... And that's before I possibly add in some of the 32bit math routines I've been checking out from Scenix/SXlist :-) Estimates there are up to 443 cycles max for each calculation (32 bit divide, 32 multiply). Not sure I'm going to go there though, unless I make the motor encoder and velocity engine it's own SX (instead of bundled in with servo control and the like). ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=269425#m269461 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)