1. Robotic arm out of control
- Posted by Stephen Spencer <stephen.spencer at USA.NET> Mar 01, 1998
- 625 views
Hello, At the moment I am making for a school project a program in Euphoria to control a robotic arm (to make it play a game of Solitaire - you know, the one where you jump balls over each other on a board until you only have one left). I have a little test program I made because the main program didn't work when I added the code to move the arm: include get.e constant pos={600,300,200,100,90} object arm arm = open("COM1", "ub") puts(arm,3) -- Init puts(1,"Arm initialised.\n") puts(arm,128) --Three-byte coords for Axis 1 puts(arm,floor(pos[1]/256)) puts(arm,remainder(pos[1],256)) puts(arm,129) --Three-byte coords for Axis 2 puts(arm,floor(pos[2]/256)) puts(arm,remainder(pos[2],256)) puts(arm,130) --Three-byte coords for Axis 3 puts(arm,floor(pos[3]/256)) puts(arm,remainder(pos[3],256)) puts(arm,131) --Three-byte coords for Axis 4 puts(arm,floor(pos[4]/256)) puts(arm,remainder(pos[4],256)) puts(arm,137) --Three-byte coords for Rotating table puts(arm,floor(pos[5]/256)) puts(arm,remainder(pos[5],256)) if wait_key() then end if close(arm) What happens is that the 'Arm initialised' message comes up after about 2 seconds (I'm forced to run this on a 386 SX-16!) and then the arm does absolutely nothing. It only moves to the correct postion after I press a key. I assume this is because of some outgoing buffer that is forced upon me by Euphoria which is automatically flushed when I close the device. Of course I could continally open and close the arm to avoid this, but then it means waiting two seconds all the time. All the commands are correct and the equivalent code in QBasic (PRINT #1,chr$(xxx);) works fine. I didn't have much time on Friday to test this problem - am I missing something obvious here or do I have to use some flush_buffer() or similar command? Thanks, Stephen Spencer stephen.spencer at usa.net p.s. Does anybody want the arm-communication disabled version of the full program (that works!) so you can play a game of solitaire?
2. Re: Robotic arm out of control
- Posted by Robert Craig <rds at EMAIL.MSN.COM> Mar 01, 1998
- 629 views
- Last edited Mar 02, 1998
Stephen Spencer writes: > It only moves to the correct postion after I press a > key. I assume this is because of some outgoing buffer that is forced > upon me by Euphoria which is automatically flushed when I close the > device. Of course I could continally open and close the arm to avoid > this, but then it means waiting two seconds all the time. I haven't done much work with the COM1 device. Maybe someone else can give you more information. I do know that the CON (console) device does line buffering - which means it will flush whenever you send a '\n' end-of-line character to it, or you close() it. Maybe COM1 is the same - try it. Euphoria itself is not doing any buffering of COM1, unless maybe the WATCOM library is. Regards, Rob Craig Rapid Deployment Software
3. Re: Robotic arm out of control
- Posted by Stephen Spencer <stephen.spencer at USA.NET> Mar 02, 1998
- 635 views
- Last edited Mar 03, 1998
Thanks Rob, Yes it was to do with \n. If you have an external modem with flickery lights, you can see the problem. ----------------------------------------- include get.e object modem modem = open("COM1", "ub") puts(1,"I'm going to send \'AT\' to the modem (standard test)...\n") puts(1,"Press a key to begin or Ctrl-C to quit") if wait_key() then end if puts(modem,'a') puts(1,"\n\nI've sent an a...") puts(1," You should have seen no flickering lights...\n") if wait_key() then end if puts(modem,'t') puts(1,"I've sent a t...") puts(1," You should have seen no flickering lights...\n") if wait_key() then end if puts(modem,'\n') puts(1,"I've sent \\n...\n") puts(1,"The buffer should have flushed and the modem flickered!\n\n") puts(1,"Press a key to quit...") if wait_key() then end if close(modem) ----------------------------------------- It's a good job characters 10 and 13 (\n) don't do anything on the robotic arm or I would be in trouble then! My arm-controlling program still probably won't work, but you never know! I'll be putting the stand-alone and with-arm versions on my website once I've finished it and I'll let you all know how it went. Many Thanks, Stephen Spencer stephen.spencer at usa.net p.s. I've given up with the idea of the diskmag intro, so can you just send any interesting articles to the above address, and I'll sort out all the formatting and stuff when I get them. Expect the full diskmag out in a couple of months (when all my coursework is out of the way!)