boe-bot printer robot
maad
Posts: 28
I have this robot that when it moves, it prints whatever I write to its eeprom memory, because basic stamp has no practical gui, I came with the idea of writing my text using visual studio but I'm stuck with the programming.Im gonna publish the code for visual basic and for my basic stamp, perhaps someone has the time to give me a hand with this, any comment or hint will be gratefully received.Here's the code for vb...
Public Class Form1
this is the design form:http://img59.imageshack.us/i/form1ku.jpg/
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim send As String = Val(TextBox1.Text)
If _port.IsOpen Then
_port.WriteLine(send)
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
'code goes here to send string text to microcontroller basic stamp
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPort1.Open()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'code goes here /toggle switch, puts pin1 in microcontroller in high state when button is pressed
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'code goes here / momentary button, puts pin0 in microcontroller in high state while button is depressed
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
'code goes here to read text from microcontroller
End Sub
End Class
And here is the code for my stamp:
' =========================================================================
'
' File.......
' Purpose....
' E-mail..... cearza@hotmail.com
' Started.... March 30 2011
' Updated....
' Dvlpd by...
' {$STAMP BS2p}
' {$PBASIC 2.5}
'
' =========================================================================
'
[ Program Description ]
' THIS PROGRAM IS PRETENDED TO WRITE TEXT FROM VISUAL BASIC TO A BOEBOT ROBOT USING THE SERIAL PORT.
'THIS CODE IS ONLY TO SEND LOCAL CHARACTERS TO HP DRIVER AS STATED ON EEPROM DATA LINE BELOW,
' THERE IS NO CODE AT ALL TO RECEIVE INSTRUCTIONS FROM VISUAL BASIC.
'
[ I/O Definitions ]
Inkjet PIN 15 ' to HP driver
button2 PIN 1 'from visual basic
button3 PIN 0 'from visual basic
'
[ Constants ]
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T9600 CON 84
#CASE BS2SX, BS2P
T9600 CON 240
#CASE BS2PX
T9600 CON 396
#ENDSELECT
SevenBit CON $2000
Inverted CON $4000
Open CON $8000
Baud CON Open + T9600
Prompt CON ">" ' prompt from HP driver
STX CON 2 ' start of text
ETX CON 3 ' end of text
Esc CON 27 ' escape
'
[ Variables ]
msgPntr VAR Word ' points to msg in EE
char VAR Byte ' character to print
'
[ EEPROM Data ]
Msg1 DATA STX, " text from visual basic go here ", ETX
'
[ Main Routine ]
Reset:
msgPntr = Msg1
GOSUB Print_String
SEROUT Inkjet, Baud, [Esc, "C", 15] ' intercolumn delay 1.5 ms
SERIN Inkjet, Baud, 500, No_Inkjet, [WAIT(Prompt)]
END
'
[ Subroutines ]
No_Inkjet:
' handle no response from Inkjet here
GOTO Reset
Print_String:
DO
READ msgPntr, char ' get character from msg
SEROUT Inkjet, Baud, [char] ' send to print driver
msgPntr = msgPntr + 1 ' point to next char
LOOP UNTIL (char = ETX) ' done at ETX
Public Class Form1
this is the design form:http://img59.imageshack.us/i/form1ku.jpg/
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim send As String = Val(TextBox1.Text)
If _port.IsOpen Then
_port.WriteLine(send)
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
'code goes here to send string text to microcontroller basic stamp
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPort1.Open()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'code goes here /toggle switch, puts pin1 in microcontroller in high state when button is pressed
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'code goes here / momentary button, puts pin0 in microcontroller in high state while button is depressed
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
'code goes here to read text from microcontroller
End Sub
End Class
And here is the code for my stamp:
' =========================================================================
'
' File.......
' Purpose....
' E-mail..... cearza@hotmail.com
' Started.... March 30 2011
' Updated....
' Dvlpd by...
' {$STAMP BS2p}
' {$PBASIC 2.5}
'
' =========================================================================
'
[ Program Description ]
' THIS PROGRAM IS PRETENDED TO WRITE TEXT FROM VISUAL BASIC TO A BOEBOT ROBOT USING THE SERIAL PORT.
'THIS CODE IS ONLY TO SEND LOCAL CHARACTERS TO HP DRIVER AS STATED ON EEPROM DATA LINE BELOW,
' THERE IS NO CODE AT ALL TO RECEIVE INSTRUCTIONS FROM VISUAL BASIC.
'
[ I/O Definitions ]
Inkjet PIN 15 ' to HP driver
button2 PIN 1 'from visual basic
button3 PIN 0 'from visual basic
'
[ Constants ]
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T9600 CON 84
#CASE BS2SX, BS2P
T9600 CON 240
#CASE BS2PX
T9600 CON 396
#ENDSELECT
SevenBit CON $2000
Inverted CON $4000
Open CON $8000
Baud CON Open + T9600
Prompt CON ">" ' prompt from HP driver
STX CON 2 ' start of text
ETX CON 3 ' end of text
Esc CON 27 ' escape
'
[ Variables ]
msgPntr VAR Word ' points to msg in EE
char VAR Byte ' character to print
'
[ EEPROM Data ]
Msg1 DATA STX, " text from visual basic go here ", ETX
'
[ Main Routine ]
Reset:
msgPntr = Msg1
GOSUB Print_String
SEROUT Inkjet, Baud, [Esc, "C", 15] ' intercolumn delay 1.5 ms
SERIN Inkjet, Baud, 500, No_Inkjet, [WAIT(Prompt)]
END
'
[ Subroutines ]
No_Inkjet:
' handle no response from Inkjet here
GOTO Reset
Print_String:
DO
READ msgPntr, char ' get character from msg
SEROUT Inkjet, Baud, [char] ' send to print driver
msgPntr = msgPntr + 1 ' point to next char
LOOP UNTIL (char = ETX) ' done at ETX
Comments