Shop OBEX P1 Docs P2 Docs Learn Events
HexCrawler — Parallax Forums

HexCrawler

PengatomPengatom Posts: 21
edited 2005-05-04 02:32 in General Discussion
Hi

I've upgraded(?) my HexCrawler from a BasicStamp 2 to a JavelinStamp microprossesor. Now I'm trying to put the new java code together since I have'nt found it·anywhere on Parallax's pages or her on the forums.

For now I've just programed it for testing just one servomotor with the PSC. The thing is though, when I move the joystick, it takes almost 2 sec before the servo motor moves.

I've tried to do many commands in a row, and the Javelin remembers and excecute everyone, but it has this 2sec delay...

Is it anyone who have had similar problems and know how to speed up things?

I'll attach my work so far

regards

Trond

Comments

  • Jon KeinathJon Keinath Posts: 146
    edited 2005-05-03 16:07
    Trond,
    I had the same sort of problem when I started programing my Javabot, what solved this problem for me was increasing the baud rate. I don't have my code with me (i'm at work) but I will post the code when I get home tonight.

    -Jon
  • Jon KeinathJon Keinath Posts: 146
    edited 2005-05-03 23:18
    Trond,

    Here is the code you have been waiting for...

    I create 2 uarts (one for the initial baud, and one for the faster baud) something like this.
    static Uart scBaud = new Uart(Uart.dirTransmit,CPU.pin13,Uart.dontInvert,
                                      Uart.speed2400,Uart.stop1);
    static Uart txUart = new Uart(Uart.dirTransmit,CPU.pin13,Uart.dontInvert,
                                      Uart.speed38400,Uart.stop1);
    


    Then at the start of my main I send the psc the update baud command like this...
        //Set PSC Baud rate to 38400
        CPU.delay(5000);               //Wait for servo controler to boot
        scBaud.sendString("!SCSBR");   //Set baud
        scBaud.sendByte(1);            //Set baud to 38400
        scBaud.sendByte(0x0D);
        CPU.delay(5000);               //Wait for servo controler to get new baud
    
    


    You can then use the txUart for all further communication at the new higher baud.
    I added this to your existing code, and attached it. I plan on posting alot of this stuff on my website, but haven't had the time to do it yet. When I do it will be available HERE (currently it has pictures and information about my JavaBot.)
  • Kevin B SlaterKevin B Slater Posts: 49
    edited 2005-05-04 00:21
    If I may be so bold as to offer a suggestion.· Could you not do a restart on the Uart with the new baud rate, for example.
    // Set the initial baud rate at 2400
    static Uart txUart = new Uart(Uart.dirTransmit,CPU.pin13,Uart.dontInvert,
                                      Uart.speed2400,Uart.stop1);
    
    //Set PSC Baud rate to 38400
    CPU.delay(5000);               //Wait for servo controler to boot
    txUart.sendString("!SCSBR");   //Set baud
    txUart.sendByte(1);            //Set baud to 38400
    txUart.sendByte(0x0D);
    CPU.delay(5000);               //Wait for servo controler to get new baud
    
    //Restart the Uart with the baud rate set to 38400
    txUart.restart(Uart.dirTransmit,CPU.pin13,Uart.dontInvert,Uart.speed38400,Uart.stop1);
    


    I am not where I can test this, so if it doesn't work please forgive me.· this would just seem to eliminate the generation of an additional VP , which are at a premium.

    Kevin
  • Jon KeinathJon Keinath Posts: 146
    edited 2005-05-04 01:17
    Kevin,
    I tried your idea with some of my code, and it works great, thanks for the tip. I guess I haven't had a problem with running out of VP's yet so I wasn't aware of the uart restart. Thanks again for the tip!

    -Jon
  • Kevin B SlaterKevin B Slater Posts: 49
    edited 2005-05-04 02:32
    Jon,

    · Great! Glad it worked, I am always hesitant to suggest something with out trying it first.· Most of the time one would not run out of VPs, there are only six·allowed to run at a time though.· I mean no offense when I say this, I just think it is cleaner code.· No reason to create something that you use once and never use again.
    · Love your robot by the way, my son thought it was cool too; he liked how it followed the light in the video on the web page.
    ·

    Kevin

    P.S. That does pose·another question, has anyone written classes to use the PSC?
Sign In or Register to comment.