fbpx

Expresate

Si además quieres enviarnos un Artículo para el Blog y redes sociales, pulsa el siguiente botón:

Avisos
Vaciar todo

Conectar un BasicX a una SSC-32

3 Respuestas
2 Usuarios
0 Reactions
1,257 Visitas
norut
Respuestas: 13
Topic starter
(@norut)
Active Member
Registrado: hace 16 años

Hola, soy muy novato en esto de la robótica, aunque poco a poco voy entrando ... y me atrevo con lo siguiente.

Tengo problemas intentando conectar un microprocesador BasicX-24 con una controladora SSC-32. He configurado la SSC-32 a 9600 bauds, y conectado el pin RX al pin 9 del BasicX. El pin del ground lo he conectado al 4 del BasicX

Estoy utilizando el código siguiente, extraido de la web de Netmedia. Veo el led de la SSC-32 haciendo un flash una vez, lo que quiere decir que algo recibe, pero el servo no se mueve.

De hecho tengo dos códigos diferentes, pero ninguna de los dos me funciona. ¿Hay alguien que me pueda echar un cable?

CODIGO 1
--------------

private const InBufSize_3 as INTEGER = 13 ' 4-byte buffer.
private const OutBufSize_3 as INTEGER = 10 ' 1-byte buffer.
private InBuf_3(1 To InBufSize_3) as BYTE 'matriz
private OutBuf_3(1 To OutBufSize_3) as BYTE 'matriz
Dim Move As String * 20

Sub Main()

debug.print "serial port definition"
call OpenSerialPort_3(9600)

debug.print "move servo - 1"
Move = "#5 P1600"
Call PutLine_3(Move)

debug.print "move servo - 2"
Move = "#5 P1200"
Call PutLine_3(Move)

debug.print "that's all"

End Sub

sub OpenSerialPort_3(ByVal BaudRate as LONG)
CALL OpenQueue(InBuf_3, InBufSize_3)
CALL OpenQueue(OutBuf_3,OutBufSize_3)
CALL DefineCom3(8, 9, bx1000_1000)
CALL OpenCom(3, BaudRate, InBuf_3, OutBuf_3)
END sub

public sub PutLine_3(ByRef Tx as STRING) ' Outputs a STRING type, followed by <CR> <LF>. Output is to serial port n.
CALL PutStr_3(Tx)
CALL NewLine_3
END sub

public sub PutStr_3(ByRef Tx as STRING) ' Outputs a STRING type to serial port n.
dim Length as INTEGER
dim Ch as STRING * 1
dim bCh as BYTE
dim I as INTEGER

Length = Len(Tx)
For I = 1 To Length
Ch = Mid(Tx, I, 1)
bCh = Asc(Ch)
CALL PutByte_3(bCh)
NEXT
END sub

sub PutByte_3(ByVal Value as BYTE)
CALL PutQueue(OutBuf_3, Value, 1)
end sub

public sub NewLine_3() ' Outputs a <CR> <LF> to serial port n.
CALL PutByte_3(&h0D)
' CALL Sleep(5) ' delay not used in the NetMedia BX-24 version.
CALL PutByte_3(&h0A)
END sub

CODIGO 2
-------------

Sub Main()

Dim OCom(1 To 30) As Byte
Dim ICom(1 To 30) As Byte
Dim Move As String * 20
Dim CRCL as String * 20
CRCL= Chr(13)' & Chr(10)

debug.print ""
debug.print "definimos puerto serie"
Call OpenQueue(OCom, 30)
Call OpenQueue(ICom, 30)
CALL DefineCom3(8, 9, bx1000_1000) ' serial port, inverted, 8 bits, no parity, 1 stop bit.
Call OpenCom(3, 9600, ICom, OCom)

call delay(0.1)
debug.print "mover servo - 1"
Move = "#5 P1600"
Call PutQueueStr(OCom, Move)
Call PutQueueStr(OCom, CRCL)

call delay(0.1)
debug.print "mover servo - 2"

Move = "#5 P1200"
Call PutQueueStr(OCom, Move)
Call PutQueueStr(OCom, CRCL)

call delay(0.1)
debug.print "ya esta"

End Sub

----------------------------------------------------------------------------------

A ver si me podeis ayudar.

Gracias por adelantado

Responder
2 respuestas
norut
Respuestas: 13
Topic starter
(@norut)
Active Member
Registrado: hace 16 años

Bueno, por si a alguien le sirve para el futuro, ya lo he solucionado. La instrucción

CALL DefineCom3(8, 9, bx1000_1000)

tiene que ser

CALL DefineCom3(8, 9, bx0000_1000)

Lo que hace un cero a la izquierda !!

Responder
ranganok
Respuestas: 3875
(@ranganok)
Ardero
Registrado: hace 19 años

Yo lo que generalmente hago para depurar es utilizar el puerto serie o algún led conectado a la placa para saber que está pasando por ahí.

Siento no haberte podido ayudar más pero el Basic lo tengo muy olvidado.

S2

Ranganok Schahzaman

Responder
Compartir: