Shop OBEX P1 Docs P2 Docs Learn Events
Mach 3 cnc controller communication — Parallax Forums

Mach 3 cnc controller communication

ZaaephodZaaephod Posts: 3
edited 2010-06-16 18:02 in BASIC Stamp
Hello all,

While I'm not new to coding, I am new to the basic stamp and its syntax. I have a BS2 v1.0, using editor 2.5.

Mach 3 is CNC controller software that allows some VB scripting.
I have simple Mach3 vbscript that sends some data:
call sendserial(0)



Then, I have this bs2 code, watching for incoming data:

Like I said, I'm new to the bs2 syntax, so I'm sure the -48 isn't the best solution, but it does work. I've done some testing, and sending 0, 1, 2, 3, etc. will trigger the corresponding pin on the bs2.

The problem is, it seems like each time the code receives any data at all, it resets the stamp. The reason I say this is, I have an LED attached to pin 0. if I send the stamp data "0" once, the light comes on, but when I send it again, it just blinks, instead of turning off like you'd expect with the toggle command. I don't understand why I'm seeing this behavior.

Thanks [noparse]:)[/noparse]

' {$STAMP BS2}
' {$PBASIC 2.5}

sData VAR Byte
insignal VAR Byte

DO

  SERIN 16, $4054, [noparse][[/noparse]sData]   ' 4800 baud
  insignal = sData -48 ' the incoming data is a character decimal value, so -48 to get the true number (not the best way, I'm sure)

TOGGLE insignal

LOOP

STOP


Post Edited (Zaaephod) : 6/16/2010 1:58:56 PM GMT

Comments

  • BeanBean Posts: 8,129
    edited 2010-06-16 14:00
    The stamps use a signal from the serial port to reset them (I think it is DTR).
    You need to make sure that signal stays in the correct state (low I think) otherwise it will reset the stamp.

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.
    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There are two rules in life:
    · 1) Never divulge all information
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    If you choose not to decide, you still have made a choice. [noparse][[/noparse]RUSH - Freewill]
  • ZaaephodZaaephod Posts: 3
    edited 2010-06-16 14:13
    Hmm, now how to get that to actually happen..

    When you said that, the first thing I did was to run over and test the stamp code by sending data from hyperterminal, and it works perfectly. LED on, LED off.

    Unfortunately, the Mach3 documentation really doesn't give any details about how to use the sendserial function, it seems to be something that was put in, but most people have never used it. Unless this can somehow be remedied by adding character codes or something to the incoming command, or the DTR reset can somehow be disabled in the stamp, I may have just hit a game breaking wall.

    Thanks,
    Z
  • ZaaephodZaaephod Posts: 3
    edited 2010-06-16 18:02
    Came up with a solution. We made a male to female serial adapter with a momentary push button in line with the DTR pin. You have to hold the button down to send the program to the BS2, but the opening / closing of the port that I can't control from the output software doesn't have any effect then.

    [noparse]:)[/noparse]

    Thanks for the info, Bean, that's what I needed to know to fix the problem.
Sign In or Register to comment.