by LROBBINS » 13 Sep 2012, 22:22
Hi All,
Rachi had surgery this morning so I've had only a few minutes to look at the forums. The surgery (removal of the C6-7 disc, placing of a spacer, a reinforcing plate and a cage) went well, Rachi was still pretty dopey when I left at 6PM, but Ellen said that she was more responsive toward 9PM. It will be a day or two before we know whether this, following replacement of her baclofen pump and catheter 3 weeks ago, will resolve the horrid problems she's had the last several months.
Just a few comments on the latest batch of postings.
John,
The reason to bring up Arduino is that it can add some useful functions that the Roboteq doesn't have - such as the ability to display information and to log operating/service/fault information to display or later download. For example, I've now written a very little subroutine that can track cumulative current draw for as long as the chair is on - actual Amp-Hrs used, but with just the Roboteq there's no way to either store or display that information; storage so that one can accumulate Amp-hours even if the chair has been turned off for some time between charges, display or it's useless information. An Arduino could retrieve the info, store it continuously in its memory even when the controller is turned off, retrieve it from memory and keep adding when the chair is again on, and display Amp-Hrs used on a small lcd screen. Same for any of the other Roboteq-generated information that you can see on your PC, a device impractical to use while driving.
Timing. So, taking out the PRINT statements removes a lot of delay (probably mostly from the Roboteq added wait after every 32 characters). I hope you commented out the PRINTs rather than physically deleting them. Comments cost nothing, they're not even in the compiled code downloaded into the controller. They can, however, be very useful later on if you want to modify or debug something.
You may also find that the program runs faster when the PC is not connected, and that the actual chair will respond smoothly with a longer wait than will the PC. Indeed, as that wait time give more processor resources to chair control rather than the script, there's probably some optimum length that balances chair-control and script needs. It may be something you want to fiddle with when you have it on the chair.
While Rachi was in the OR, I did works some more on the script. I have a SpeedPot subroutine and the one mentioned above for integrating current flow (though that was more for curiosity than for usefulness without some way to display it). I also cleaned up some of the code so it runs more smoothly (though the small difference probably will be unnoticeable), made the comments and some variable names more meaningful etc. After things calm down here, I send it along so everyone can take a look at it and tell me what more is wanted.
I also have a couple very small scripts for testing a couple things that can only be tested with a controller connected; to check out my use of the Get Input _TM (time) instruction (the table in the manual has an error, so it must be field tested), and another to help me find out how long different kinds of instructions take to execute; in particular a simple IF versus a series of multiplications. Again, optimizing code in this way probably won't make a real-world difference, but it's really no harder to write efficient code than to write bloat and this has to run well on a really micro, microprocessor. Again, I'll send them along when I find time to describe what needs to be tested.
Next, perhaps now that you know that the apparent "serial takeover" happens whenever a script is running, you may find that you actually can use a serial input device without a real conflict. It might be possible to put back Mode 2 and configure the driving inputs for serial as well.
Finally, a little dictionary of Arduino speak. Arduino was invented by a small group of (typically crazy) Italians who wanted to show graphic and performing artists, and even designers of alta moda, that it's really not hard to add computer-based automation to their art. One of the ways chosen to break through the culture barrier was to call Arduino programs not "scripts" but "sketches". Shield is another one, though it doesn't seem to me to have an art connection. These are circuit boards for add-on functions, there are now hundreds if not thousands of these, that directly plug in on top of an Arduino board; many can even stack one on top of the other. So you can add a board with multiple relays, or a board with MOSFETS to use the Arduino PCM ouputs for motor control, or to add screen output for text or graphics, or with a CAN interface. The way I built the accelerometer stability enhancer for Rachi's chair is as an Arduino screen. It has the accelerometer, a 4046 and some connections to mini phone plugs, and just stacks with matching headers on top of the Arduino. The Arduino programming language is a subset of C++ unlike Roboteq's subset of Basic, but it is a lot more complete. For example, it does have real number arithmetic, many different variable types - not just integer and TRUE FALSE, but things like character strings, and lot's of people have posted pieces of code on the Arduino forums for doing lots of things. Another is that you can send and receive serial data of any form and control serial flow, not just "characters" and variables. The software also arrives with numerous examples, many with good explanatory comments, to help one learn. I actually don't particularly like writing in C++, it has lots of abbreviated ways of saying things that professional programmers for some reason like, perhaps only because they have to type less, but that I find makes the programs hard to read. For example, instead of writing a = a + 1, in C++ one writes just a++, but you have to remember that ++a and a++ mean different things. The basics of programming are exactly the same, however: get data, store data, do arithmetic, branch and loop.
I wouldn't use an Arduino for primary chair control, nor would I want the Roboteq to be dependent on a properly functioning Arduino; it just doesn't have the safety engineering of a Roboteq. But for ancillary functions, such as a battery meter based on AmpHrs used, lighting, actuators etc., it could be handy. I'll try to describe one concrete example of useful data logging. The Roboteq can stop the chair (in a few different ways) if there's a brake fault, an output stage fault, a joystick fault and so on. If you look at its few lights when that happens, you might get some idea what faulted. If you logged the fault flags and the named variables of interest, and translated fault flags to human-readable text, you could hook up your PC or use your Arduino with a screen and know a lot more about what's broken. There are also faults that the Roboteq itself doesn't detect that could be monitored from a script: excess current in an current sensor chip with respect to drive commands -- maybe there's a short in the motor, no current even when the motor is told to go - it's probably an open, not a broken gear case, and so on.
Lastly, because the MotorCompensation is set as milliohms, your starting value should be something less than the actual milliohms of your motor+wiring and then make little adjustments from there just as on any other controller. The only thing that's on the latest Dynamic or P&G that you won't have is a way of measuring motor resistance using the controller, but if your cautious and start low, that's not a big deal. Keep your emergency cut off lanyard in hand in case the script, or your guess of milliohms, is screwed up and the chair takes off on its own.
Ex-Gooserider,
It will be interesting to see what your fellow hackers have to say. One thing somewhat off-putting about Arduino, for example for a display, is that the versions that mate with standard shields are rather large, about 2" x 3". That's small if it's tucked away inside the chair, so could be used that way as a data logger and extra auxilliary output device, but large if you want it in pod or small stand-alone information display. The brains could be in the chair, and the screen remote, but that means a multi-wire Arduino-to-screen cable instead of just a 2 wire serial connection. There are a number of smaller Arduino boards, but you'd probably have to design your own shields to use them.
OK, I've got to get some sleep. No energy left to preview and edit, so what I wrote is what you'll get.
Ciao,
Lenny