Shop OBEX P1 Docs P2 Docs Learn Events
How to control PSC from PC? — Parallax Forums

How to control PSC from PC?

NiklasNiklas Posts: 3
edited 2005-09-04 07:14 in Robotics
Hi!

Just read that parallax are working on some software on controlling the PSC from a PC. I have built a 6-legged robot similar to the HexCrawler and I want to evolve some sort of walking gait using for example evolutionary algorithms. In order to do this I need to control the PSX from something more powerful than a Stamp, for example a PC.

My question is: Haven't anyone already managed to control the PSC from a PC? My impression is that whatever you want or need to do, somebody has already done this but still I cant find any info on it... As I see it, it should be a matter of figuring out the format of the serial message required by the PSC.

Regards Niklas

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-14 16:38
    Niklas,

    ·· As a workaround you could control the PSC from your PC through the BS2.· Simply send your commands via serial to the BS2 and have it pass them to the PSC.· But as a side-note, a stock BS2 can control a Hex Crawler just fine with 12 servos, so I'm not sure where you got the idea that a BS2 wasn't capable.· In fact many have 2 to 4 extra servos for scanning.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • dandreaedandreae Posts: 1,375
    edited 2005-04-14 20:06
    Parallax will have a USB PSC soon that will allow you to us the PC to control it.· Here is a link for more information[noparse]:http:[/noparse]//www.parallax.com/detail.asp?product_id=28823

    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Tech Support
    dandreae@parallax.com
    www.parallax.com

    ·
  • NiklasNiklas Posts: 3
    edited 2005-04-15 09:30
    The actual problem is not controlling the servos from the Stamp but to evolve a walking gait. I'm doing this as a school project where I'm supposed to learn how to·train real robots in to doing something meaningful, in this case walk. It is of course easy to hardcode the walking gait which I have done using a Stamp but this is not what I want to achieve. So, the calculations required to train the robot is far to complex for a Stamp to handle.

    Controlling the servos from a PC via·a Stamp could be worth trying. I'll look into that.

    Thanks!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-15 16:54
    Niklas,

    ·· Check this out...· http://www.parallax.com/sx/contest/contest_SX_creeper.asp



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ozneteastozneteast Posts: 1
    edited 2005-04-18 03:04
    I have found a way to get my pc to be able to send commands to my PSC.

    When interfaced to my basic stamp the green light on the PSC was normally off except for when receiving data. When I connected it to my serial port on my PC it was constantly on, which tipped me off that the signal may need to be inverted.

    I used a transistor and 2 resistors to invert the signal, and convert it to 5V at the same time, and it seems to be working fine. It communicates only one way for now (send only) which is all I need, works great.

    I know this is the dirtiest way of doing it, but I dont have a RS232 chip handy.
  • NiklasNiklas Posts: 3
    edited 2005-04-23 15:51
    What format should the message sent to the PSC have? I mean, exactly what would the serial message look like in order to tell the PSC to move a certain servo to a position with a certain ramping. I dont know what the PSC "wants"...

    /Niklas
  • paradparad Posts: 1
    edited 2005-07-08 16:49
    ozneteast can you provide a schematics of your transistor and resistors?

    We have tried something similar but the servos just won't move! We have the same problem with green light being constantly on, we tried a circuit that 'should' work but it doesn't (the led does only light when we transmit so that is correct at least). So either our circuit is wrong, or the command we are sending is wrong. We made a small program just to test it out, basically we open up the serial device, set the correct (we think) settings and write to it.

    int fd = open("/dev/ttyS0", O_WRONLY);
    termios t;
    tcgetattr(fd, &t);
    // set baudrate 2400, 8N2
    cfsetospeed (&t, B2400);
    t.c_oflag |= CSTOPB;
    t.c_oflag |= CS8;
    t.c_oflag &= ~PARENB;
    t.c_oflag &= ~PARODD;
    tcsetattr(fd, TCSANOW, &t);
    // send command
    char command[noparse][[/noparse]8];
    sprintf(command, "!SC%c%c%c%c%c", 0, 0, 250, 0, 0x0d);
    write(fd, command, 8);
    close(fd);

    Any ides anyone?
  • GerhardGerhard Posts: 17
    edited 2005-08-12 05:14
    Hi!



    I have the exact same problem. The green light is constantly on and no servo is moving. Could you please provide the schematics of the PC Interface. I'm stuck with it.



    Thank you,

    Gerhard
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-08-12 11:55
    I know this is an old thread, and its likely that Niklas' semester is already over, but the new PSC has been released by this point and a VB class to interface with it is in this thread. This should provide a suitible interface for a VB program on a PC to directly control the PSC.

    Parad and Gerhard, if a thread is more than a few weeks old (since the last time anyone posted to it), it is better to start a new thread. People who recognize it as an old thread will be less likely to read it, and wouldn't notice that you have a new question. A good rule of thumb is: go ahead and search the last 1-3 months of posts to see if your question has already been asked. If it has and the question was answered, you're done. If it has been asked, but you want more info or it is the same topic but not the exact same question, and the post is on the first or second page, attach a post to the thread with your question. If the post is quite old, start a new thread and include a link to the old post in your message; that way those of us answering questions will know its a new question. Neither of you have done anything wrong, this is just a suggestion to help·you guys to get quick and full answers.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10

    Post Edited (Paul Baker) : 8/12/2005 12:01:27 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-12 16:00
    Hello All,

    ·· Here (attached) is a schematic for the PC to PSC interface for those using Serial Versions of the PSC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
    744 x 356 - 44K
  • GerhardGerhard Posts: 17
    edited 2005-08-12 18:22
    Hi all!

    Thank's for the schematics. I got mine now talking to the PC. Green light only comes on when communicatiing. With Hyperterm I couls also request the Version. It replyed wit 1.4. Still having trouble to get any servo moving. So I still need some help on programming a Sequence in C or C++ under Linux. If anyone knows how that works, it would be appreciated.

    Regards,
    Gerhard
  • grindelgrindel Posts: 68
    edited 2005-08-12 20:20
    Gerhard,
    If you get a servo to respond through hyperterm, copy and paste it to a post would you?

    thanks,
    Nick
  • GerhardGerhard Posts: 17
    edited 2005-08-12 20:32
    grindel,

    haha, I believe I might break my fingers before that could work. But if I it happens I promise to post itwink.gif

    Cheers,
    Gerhard tongue.gif
  • cjnewbscjnewbs Posts: 8
    edited 2005-08-22 20:14
    Is there a way to test the serial to PSC interface circuit before connecting it to the PSC.

    I know this is probaly a longshot but if i connected·a LED to pin 1 and 2 of the PSC end of the circuit and got a VB6 program to continusley send &hff to the com1 port would the LED light up??

    I know this is a dumb question but·I recon it was probaly worth asking.
  • GerhardGerhard Posts: 17
    edited 2005-08-23 10:23
    Hi cjnewbs!

    Why would you like to do that? On the PSC Board is a LED that gives you a clear indication if there is any traffic that moves via the serial line from the PC to the PSC.

    Cheers,
    Gerhard
  • cjnewbscjnewbs Posts: 8
    edited 2005-08-23 10:42
    I would like to do it as I would like to get the PCB ready for when it arrives. It would be handy if I could as there would be no faffing around if it didn't work when it arrives.
  • GerhardGerhard Posts: 17
    edited 2005-08-23 10:52
    Hi cjnewbs!

    As it appears to me, you need to apply power between Pin 2 (+5V) and 3 (GND) in order to see anything at all. on Pin 1 should be an action of some kind as soon you put something from the PC towards the interface. Since the circuit echoes (or should at least) the incoming traffic, you might get some characters sent back to the PC. But that is dependend on the chip on your PC, since the voltages are differnt on RS232C (+/- 12V) than on TTL(+5/0V). But it's worth a try.

    Hope I could help a little,
    Gerhard
  • cjnewbscjnewbs Posts: 8
    edited 2005-08-27 22:52
    Does Power need to be applied to the blue screw terminals on the PSC when running commands such as !SCVER ??

    Thanks
  • GerhardGerhard Posts: 17
    edited 2005-08-28 05:29
    Hi cjnewbs!

    No for requesting the version number that is not needed. You need power on these terminals as soon as you want to move or hold the servos. By the way does the interface work for you? I am courious, because I set up a small PCB with a MAX232 and 5V Power Supply to make sure that the communication works correctly.

    Regards,
    Gerhard
  • cjnewbscjnewbs Posts: 8
    edited 2005-08-28 21:23
    The prototype board version of the interface circuit I trued did not work - not sure why. I then made a pcb to see if I could get any better results - still nothing. I then checked the circuit board. The collector and base pins on the 2n3906 were shorted out, which i then corrected. I then tried to send !SCVER [noparse][[/noparse]ENTER] to the PSC in hyperterminal again. Still nothing. Could I have damaged the Serial port of the computer, the pcb I made, or the PSC.

    Jeez - I hope i havent damaged anything.

    Thanks

    BTW - Whats a MAX232??

    Post Edited (cjnewbs) : 8/28/2005 9:41:12 PM GMT
  • GerhardGerhard Posts: 17
    edited 2005-08-29 05:31
    Hi cjnewbs!

    Sorry to hear about that. To make sure that your RS232 TX/RX works correct, maybe you should get one of these testers with LED's. there you can see if you get any action when you type something in Hyperterm. If you want just an echo, short out Line 3 and 2 temporarely on a separate connector. If you see anything on the terminal, your computer is fine. Another thing is, do you know if the Computer is wired as DTE or DTS? to find out maybe·switch line 3 and 2 on your end (had that happen many times...).· If that all does not help, you will need to get a voltage level converter like the MAX232. With that my stuff works like a charm. Well and the question if you have damaged anything, I don't know but it is not very likely.

    I get my PCB's this week. If everything checks out fine I will give you the schematics and the Layout. The headaches will be over with that;-)

    Best Regards,
    Gerhard
  • TerryTerry Posts: 1
    edited 2005-08-30 15:30
    Gerhard - Take a quick look at http://servomaster.sourceforge.net/

    Open source project that seems to offer exactly what you need.

    -Terry
  • GerhardGerhard Posts: 17
    edited 2005-08-30 17:37
    Hi Terry!

    Thanks for pointing me there. Looks like very interesting site.

    By the way, the PCB I designed checked out perfectly. When I get to my Computer I will post the schematics and the PCB design. Maybe I pack also the Linux Software for testing the servos into that too.

    Cheers,
    Gerhard
  • GerhardGerhard Posts: 17
    edited 2005-08-30 19:55
    Hi everyone!

    As promised attached the Files regarding the RS232 converter and the software I'm using for testing. Please note there are no warranties whatsoever. I's your responsibility if you use it...... (It works for me...)

    Best Regards,
    Gerhard
  • cjnewbscjnewbs Posts: 8
    edited 2005-08-31 22:51
    Im still having problems unfortunatly. I got a Serial plug and soldered a wire in between pins 2 and 3, and tested by typing in hyperterminal on 2 computer - nothing - any suggestions guys??
  • GerhardGerhard Posts: 17
    edited 2005-09-01 05:07
    Hi cjnewbs!

    Unfortunately there is more involved. First you have to set up the flow control properties. You could try to set them up for 'none', that might help to get over the first hump.·If that does not help, the DTR (Data Terminal Ready) and DSR (Data Set Ready) lines (have the pin numberd not handy at the moment) need to be wired. If theses lines are not set up properly the computer thinks there is noone on the other line and ignores incomind signals and refuses to send anything. When I get home I will look the pin numbers up and post them to you.

    Have fun,
    Gerhard
  • cjnewbscjnewbs Posts: 8
    edited 2005-09-03 23:50
    Have you had any luck on the serial pinouts??

    I did manage to get an echo by shorting pins 2-3, and setting flow control to None.

    I did manage to get some garbled text while i was typing !SCVER - but this only happened twice, im guessing it could have been interferance.

    Thanks.
  • GerhardGerhard Posts: 17
    edited 2005-09-04 07:14
    Hi cjnewbs!

    Well, that is good news! You don't even need to bother with the DTR and DSR lines. Downside ist, now you need to get the signals right from and to the PSC. Further up in this thread there is a schematic with two transistors. Maybe that helps. But I suggest using the MAX232 chip in order to get a proper communication. Only a few electronic parts are needed. You can see a few posts up also a schematic, PCB design and a C program that I am using. No problems since then.

    Cheers,
    Gerhard
Sign In or Register to comment.