Shop OBEX P1 Docs P2 Docs Learn Events
C# and psc (parallax servo controll) — Parallax Forums

C# and psc (parallax servo controll)

kybrkybr Posts: 3
edited 2006-08-07 05:45 in Learn with BlocklyProp
Hi,

im trying to control my psc directly from my computer with c# and without any basic stamp or anything. im using the serialport class in .net 2.0 , but cant get it to work.
when i send the psc the !SCVER command it just echos it, and i cant get the version number right.
i can controll the servos with the psci program from parallax ofcourse, so my setup is right [noparse]:)[/noparse]

what i got so far is something like this:

void main blablablba
{
SerialPort sp = new SerialPort();
sp.setcomport = COMX
sp.Write("!SCVER\r");
Console.writeline(sp.readline());
}
and that only writes !SVCER\r to my console....

anyone have some example code on how to get the version number just to get me started?
all help appriciated [noparse]:)[/noparse]


-stian

Comments

  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-07-21 03:18
    What are your other serial port parameters in C#?
  • kybrkybr Posts: 3
    edited 2006-07-21 07:46
    i·have tried with·readtimeout 500, writetimeout 500, databits 8 and baudrate 2400.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-21 08:06
    kybr -

    I know NOTHING about C# so these are just random suggestions. Should the following:

    sp.setcomport = COMX

    perhaps be pointing to the actual comm port - say COM1 ?

    What about parity, what does it default to? Given a choice, NONE is best.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-21 08:16
    kybr -

    Perhaps this article will be helpful:
    http://msdn.microsoft.com/msdnmag/issues/02/10/netserialcomm/

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • kybrkybr Posts: 3
    edited 2006-07-21 08:40
    i set i to com4 [noparse]:)[/noparse] the code i wrote was just an exaple.·i think the parity defaults to none.
    but i will try to set it just to be sure.
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-07-21 19:46
    Can you post your code as an attachment?
  • CJCJ Posts: 470
    edited 2006-07-21 21:49
    do you have a proper level shifter?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who says you have to have knowledge to use it?

    I've killed a fly with my bare mind.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-08-07 05:45
    Look here:
    http://msmvps.com/blogs/coad/archive/2005/03/23/39466.aspx

    I have used the mentioned SerialPort class without any problems.

    regards peter
Sign In or Register to comment.