Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Sponsor

controlSUITE™ software
Comprehensive.
Intuitive.
Optimized.

Real-world software for real-time control. Details Here!

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | BasicX | Serial communication problem

Discussion forum for the BasicX family of microcontroller chips.

Serial communication problem - "zack.nathan" - Jul 10 14:15:50 2009

Ok so basically i have built a robotic arm and would like to control it from the computer. I have done the application for the computer and it works. I have also programmed the firmware for the bx-24 chip. However when i turn it on, all the servo's move so the arm looks like it is having a spasm. I dont know why this is. Could someone please check through it and tell me whats wrong, many thanks, zack.

CODE:
Dim Data(1 To 3) As Byte ' defne variables
Dim Com1_In(1 To 40) As Byte
Dim Com1_Out(1 To 20) As Byte
dim baseservo as single
dim basejointservo as single
dim middlejointservo as single
dim turngripperservo as single
dim tiltgripperservo as single
dim gripperservo as single
Sub Main()
Call OpenQueue(Com1_In, 40)
Call OpenQueue(Com1_Out, 20)
Call OpenCom(1, 2400, Com1_In, Com1_Out)
' Set pins 5 - 20 to outputs
Register.DDRA = &HFF
Register.DDRC = &HFF
baseservo = 0.0 ' start of with the pulses being 0, ie not moving
basejointservo = 0.0
middlejointservo = 0.0
turngripperservo = 0.0
tiltgripperservo = 0.0
gripperservo = 0.0
Do
call pulseout(5, baseservo, 1) ' move joints
call pulseout(6, basejointservo, 1)
call pulseout(7, middlejointservo, 1)
call pulseout(8, turngripperservo, 1)
call pulseout(9, tiltgripperservo, 1)
call pulseout(10, gripperservo, 1)
If StatusQueue(Com1_In) Then
Call GetQueue(Com1_In, Data(1), 1)
If Data(1) = 255 Then ' if data byte is found do algorithm
Call GetQueue(Com1_In, Data(2), 2)
Call GetQueue(Com1_In, Data(3), 3)
' Write the 2 data byte to the BX-24 pins
Register.PortA = Data(2)
Register.PortC = Data(3)
if (Data(2) = 1) then
baseservo = csng(Data(3)) * 0.00001
elseif (Data(2) = 2) then
basejointservo = csng(Data(3)) * 0.00001
elseif (Data(2) = 3) then
middlejointservo = csng(Data(3)) * 0.00001
elseif (Data(2) = 4) then
turngripperservo = csng(Data(3)) * 0.00001
elseif (Data(2) = 5) then
tiltgripperservo = csng(Data(3)) * 0.00001
elseif (Data(2) = 6) then
gripperservo = 0.002
elseif (Data(2) = 7) then
gripperservo = 0.001
elseif (Data(2) = 8) then
exit do
end if
end if
End If
Loop

End Sub

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



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: Serial communication problem - robotlogic - Jul 10 16:39:00 2009

Zack,
It sounds like your robot arm is starving for current and the BX-24
is rebooting.

You need a minumum of 2amps of available current to run each hobby servo. Do you have that? Try starting with only 1 servo connected and see what happens.
Chris

--- In b...@yahoogroups.com, "zack.nathan" wrote:
>
> Ok so basically i have built a robotic arm and would like to control it from the computer. I have done the application for the computer and it works. I have also programmed the firmware for the bx-24 chip. However when i turn it on, all the servo's move so the arm looks like it is having a spasm. I dont know why this is. Could someone please check through it and tell me whats wrong, many thanks, zack.
>
> CODE:
> Dim Data(1 To 3) As Byte ' defne variables
> Dim Com1_In(1 To 40) As Byte
> Dim Com1_Out(1 To 20) As Byte
> dim baseservo as single
> dim basejointservo as single
> dim middlejointservo as single
> dim turngripperservo as single
> dim tiltgripperservo as single
> dim gripperservo as single
> Sub Main()
> Call OpenQueue(Com1_In, 40)
> Call OpenQueue(Com1_Out, 20)
> Call OpenCom(1, 2400, Com1_In, Com1_Out)
> ' Set pins 5 - 20 to outputs
> Register.DDRA = &HFF
> Register.DDRC = &HFF
> baseservo = 0.0 ' start of with the pulses being 0, ie not moving
> basejointservo = 0.0
> middlejointservo = 0.0
> turngripperservo = 0.0
> tiltgripperservo = 0.0
> gripperservo = 0.0
> Do
> call pulseout(5, baseservo, 1) ' move joints
> call pulseout(6, basejointservo, 1)
> call pulseout(7, middlejointservo, 1)
> call pulseout(8, turngripperservo, 1)
> call pulseout(9, tiltgripperservo, 1)
> call pulseout(10, gripperservo, 1)
> If StatusQueue(Com1_In) Then
> Call GetQueue(Com1_In, Data(1), 1)
> If Data(1) = 255 Then ' if data byte is found do algorithm
> Call GetQueue(Com1_In, Data(2), 2)
> Call GetQueue(Com1_In, Data(3), 3)
> ' Write the 2 data byte to the BX-24 pins
> Register.PortA = Data(2)
> Register.PortC = Data(3)
> if (Data(2) = 1) then
> baseservo = csng(Data(3)) * 0.00001
> elseif (Data(2) = 2) then
> basejointservo = csng(Data(3)) * 0.00001
> elseif (Data(2) = 3) then
> middlejointservo = csng(Data(3)) * 0.00001
> elseif (Data(2) = 4) then
> turngripperservo = csng(Data(3)) * 0.00001
> elseif (Data(2) = 5) then
> tiltgripperservo = csng(Data(3)) * 0.00001
> elseif (Data(2) = 6) then
> gripperservo = 0.002
> elseif (Data(2) = 7) then
> gripperservo = 0.001
> elseif (Data(2) = 8) then
> exit do
> end if
> end if
> End If
> Loop
>
> End Sub
>

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

______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Serial communication problem - "zack.nathan" - Jul 10 17:00:58 2009

Well yes, i use a RAMB II so it should be ok. But even if it were re-booting surly the servo's shouldnt move because of the variables start of value of 0.
--- In b...@yahoogroups.com, "robotlogic" wrote:
>
> Zack,
> It sounds like your robot arm is starving for current and the BX-24
> is rebooting.
>
> You need a minumum of 2amps of available current to run each hobby servo. Do you have that? Try starting with only 1 servo connected and see what happens.
> Chris
>
> --- In b...@yahoogroups.com, "zack.nathan" wrote:
> >
> > Ok so basically i have built a robotic arm and would like to control it from the computer. I have done the application for the computer and it works. I have also programmed the firmware for the bx-24 chip. However when i turn it on, all the servo's move so the arm looks like it is having a spasm. I dont know why this is. Could someone please check through it and tell me whats wrong, many thanks, zack.
> >
> > CODE:
> >
> >
> > Dim Data(1 To 3) As Byte ' defne variables
> > Dim Com1_In(1 To 40) As Byte
> > Dim Com1_Out(1 To 20) As Byte
> > dim baseservo as single
> > dim basejointservo as single
> > dim middlejointservo as single
> > dim turngripperservo as single
> > dim tiltgripperservo as single
> > dim gripperservo as single
> > Sub Main()
> > Call OpenQueue(Com1_In, 40)
> > Call OpenQueue(Com1_Out, 20)
> > Call OpenCom(1, 2400, Com1_In, Com1_Out)
> > ' Set pins 5 - 20 to outputs
> > Register.DDRA = &HFF
> > Register.DDRC = &HFF
> > baseservo = 0.0 ' start of with the pulses being 0, ie not moving
> > basejointservo = 0.0
> > middlejointservo = 0.0
> > turngripperservo = 0.0
> > tiltgripperservo = 0.0
> > gripperservo = 0.0
> > Do
> > call pulseout(5, baseservo, 1) ' move joints
> > call pulseout(6, basejointservo, 1)
> > call pulseout(7, middlejointservo, 1)
> > call pulseout(8, turngripperservo, 1)
> > call pulseout(9, tiltgripperservo, 1)
> > call pulseout(10, gripperservo, 1)
> > If StatusQueue(Com1_In) Then
> > Call GetQueue(Com1_In, Data(1), 1)
> > If Data(1) = 255 Then ' if data byte is found do algorithm
> > Call GetQueue(Com1_In, Data(2), 2)
> > Call GetQueue(Com1_In, Data(3), 3)
> > ' Write the 2 data byte to the BX-24 pins
> > Register.PortA = Data(2)
> > Register.PortC = Data(3)
> > if (Data(2) = 1) then
> > baseservo = csng(Data(3)) * 0.00001
> > elseif (Data(2) = 2) then
> > basejointservo = csng(Data(3)) * 0.00001
> > elseif (Data(2) = 3) then
> > middlejointservo = csng(Data(3)) * 0.00001
> > elseif (Data(2) = 4) then
> > turngripperservo = csng(Data(3)) * 0.00001
> > elseif (Data(2) = 5) then
> > tiltgripperservo = csng(Data(3)) * 0.00001
> > elseif (Data(2) = 6) then
> > gripperservo = 0.002
> > elseif (Data(2) = 7) then
> > gripperservo = 0.001
> > elseif (Data(2) = 8) then
> > exit do
> > end if
> > end if
> > End If
> > Loop
> >
> > End Sub
>

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



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Serial communication problem - robotlogic - Jul 10 17:40:59 2009

If I recall a pulseoout 0 still makes a pulse.
I can tell you that what you have described sounds
like a current issue, or the servos are being told
to go out of range.

Are you running your board from a good battery?

Did you try using just 1 servo?
Chris

--- In b...@yahoogroups.com, "zack.nathan" wrote:
>
> Well yes, i use a RAMB II so it should be ok. But even if it were re-booting surly the servo's shouldnt move because of the variables start of value of 0.
> --- In b...@yahoogroups.com, "robotlogic" wrote:
> >
> > Zack,
> >
> >
> > It sounds like your robot arm is starving for current and the BX-24
> > is rebooting.
> >
> > You need a minumum of 2amps of available current to run each hobby servo. Do you have that? Try starting with only 1 servo connected and see what happens.
> >
> >
> > Chris
> >
> >
> >
> > --- In b...@yahoogroups.com, "zack.nathan" wrote:
> > >
> > > Ok so basically i have built a robotic arm and would like to control it from the computer. I have done the application for the computer and it works. I have also programmed the firmware for the bx-24 chip. However when i turn it on, all the servo's move so the arm looks like it is having a spasm. I dont know why this is. Could someone please check through it and tell me whats wrong, many thanks, zack.
> > >
> > > CODE:
> > >
> > >
> > > Dim Data(1 To 3) As Byte ' defne variables
> > > Dim Com1_In(1 To 40) As Byte
> > > Dim Com1_Out(1 To 20) As Byte
> > > dim baseservo as single
> > > dim basejointservo as single
> > > dim middlejointservo as single
> > > dim turngripperservo as single
> > > dim tiltgripperservo as single
> > > dim gripperservo as single
> > > Sub Main()
> > > Call OpenQueue(Com1_In, 40)
> > > Call OpenQueue(Com1_Out, 20)
> > > Call OpenCom(1, 2400, Com1_In, Com1_Out)
> > > ' Set pins 5 - 20 to outputs
> > > Register.DDRA = &HFF
> > > Register.DDRC = &HFF
> > > baseservo = 0.0 ' start of with the pulses being 0, ie not moving
> > > basejointservo = 0.0
> > > middlejointservo = 0.0
> > > turngripperservo = 0.0
> > > tiltgripperservo = 0.0
> > > gripperservo = 0.0
> > > Do
> > > call pulseout(5, baseservo, 1) ' move joints
> > > call pulseout(6, basejointservo, 1)
> > > call pulseout(7, middlejointservo, 1)
> > > call pulseout(8, turngripperservo, 1)
> > > call pulseout(9, tiltgripperservo, 1)
> > > call pulseout(10, gripperservo, 1)
> > > If StatusQueue(Com1_In) Then
> > > Call GetQueue(Com1_In, Data(1), 1)
> > > If Data(1) = 255 Then ' if data byte is found do algorithm
> > > Call GetQueue(Com1_In, Data(2), 2)
> > > Call GetQueue(Com1_In, Data(3), 3)
> > > ' Write the 2 data byte to the BX-24 pins
> > > Register.PortA = Data(2)
> > > Register.PortC = Data(3)
> > > if (Data(2) = 1) then
> > > baseservo = csng(Data(3)) * 0.00001
> > > elseif (Data(2) = 2) then
> > > basejointservo = csng(Data(3)) * 0.00001
> > > elseif (Data(2) = 3) then
> > > middlejointservo = csng(Data(3)) * 0.00001
> > > elseif (Data(2) = 4) then
> > > turngripperservo = csng(Data(3)) * 0.00001
> > > elseif (Data(2) = 5) then
> > > tiltgripperservo = csng(Data(3)) * 0.00001
> > > elseif (Data(2) = 6) then
> > > gripperservo = 0.002
> > > elseif (Data(2) = 7) then
> > > gripperservo = 0.001
> > > elseif (Data(2) = 8) then
> > > exit do
> > > end if
> > > end if
> > > End If
> > > Loop
> > >
> > > End Sub
> > >
>

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



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Serial communication problem - "zack.nathan" - Jul 10 18:12:55 2009

Ill be trying 1 servo tomorrow, thanks. Yes, the batteries are normal rechargeable batteries. If 0.0 makes a pulse then that is probably the case. I'll try out the suggestions tomorrow. Thanks.

--- In b...@yahoogroups.com, "robotlogic" wrote:
>
> If I recall a pulseoout 0 still makes a pulse.
> I can tell you that what you have described sounds
> like a current issue, or the servos are being told
> to go out of range.
>
> Are you running your board from a good battery?
>
> Did you try using just 1 servo?
> Chris
> --- In b...@yahoogroups.com, "zack.nathan" wrote:
> >
> > Well yes, i use a RAMB II so it should be ok. But even if it were re-booting surly the servo's shouldnt move because of the variables start of value of 0.
> >
> >
> > --- In b...@yahoogroups.com, "robotlogic" wrote:
> > >
> > > Zack,
> > >
> > >
> > > It sounds like your robot arm is starving for current and the BX-24
> > > is rebooting.
> > >
> > > You need a minumum of 2amps of available current to run each hobby servo. Do you have that? Try starting with only 1 servo connected and see what happens.
> > >
> > >
> > > Chris
> > >
> > >
> > >
> > > --- In b...@yahoogroups.com, "zack.nathan" wrote:
> > > >
> > > > Ok so basically i have built a robotic arm and would like to control it from the computer. I have done the application for the computer and it works. I have also programmed the firmware for the bx-24 chip. However when i turn it on, all the servo's move so the arm looks like it is having a spasm. I dont know why this is. Could someone please check through it and tell me whats wrong, many thanks, zack.
> > > >
> > > > CODE:
> > > >
> > > >
> > > > Dim Data(1 To 3) As Byte ' defne variables
> > > > Dim Com1_In(1 To 40) As Byte
> > > > Dim Com1_Out(1 To 20) As Byte
> > > > dim baseservo as single
> > > > dim basejointservo as single
> > > > dim middlejointservo as single
> > > > dim turngripperservo as single
> > > > dim tiltgripperservo as single
> > > > dim gripperservo as single
> > > > Sub Main()
> > > > Call OpenQueue(Com1_In, 40)
> > > > Call OpenQueue(Com1_Out, 20)
> > > > Call OpenCom(1, 2400, Com1_In, Com1_Out)
> > > > ' Set pins 5 - 20 to outputs
> > > > Register.DDRA = &HFF
> > > > Register.DDRC = &HFF
> > > > baseservo = 0.0 ' start of with the pulses being 0, ie not moving
> > > > basejointservo = 0.0
> > > > middlejointservo = 0.0
> > > > turngripperservo = 0.0
> > > > tiltgripperservo = 0.0
> > > > gripperservo = 0.0
> > > > Do
> > > > call pulseout(5, baseservo, 1) ' move joints
> > > > call pulseout(6, basejointservo, 1)
> > > > call pulseout(7, middlejointservo, 1)
> > > > call pulseout(8, turngripperservo, 1)
> > > > call pulseout(9, tiltgripperservo, 1)
> > > > call pulseout(10, gripperservo, 1)
> > > > If StatusQueue(Com1_In) Then
> > > > Call GetQueue(Com1_In, Data(1), 1)
> > > > If Data(1) = 255 Then ' if data byte is found do algorithm
> > > > Call GetQueue(Com1_In, Data(2), 2)
> > > > Call GetQueue(Com1_In, Data(3), 3)
> > > > ' Write the 2 data byte to the BX-24 pins
> > > > Register.PortA = Data(2)
> > > > Register.PortC = Data(3)
> > > > if (Data(2) = 1) then
> > > > baseservo = csng(Data(3)) * 0.00001
> > > > elseif (Data(2) = 2) then
> > > > basejointservo = csng(Data(3)) * 0.00001
> > > > elseif (Data(2) = 3) then
> > > > middlejointservo = csng(Data(3)) * 0.00001
> > > > elseif (Data(2) = 4) then
> > > > turngripperservo = csng(Data(3)) * 0.00001
> > > > elseif (Data(2) = 5) then
> > > > tiltgripperservo = csng(Data(3)) * 0.00001
> > > > elseif (Data(2) = 6) then
> > > > gripperservo = 0.002
> > > > elseif (Data(2) = 7) then
> > > > gripperservo = 0.001
> > > > elseif (Data(2) = 8) then
> > > > exit do
> > > > end if
> > > > end if
> > > > End If
> > > > Loop
> > > >
> > > > End Sub
> > > >
> > >
>

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



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Re: Serial communication problem - Tom Becker - Jul 10 19:17:03 2009

My money is on Load Induced Processor Resets, too.

Later, you might be able to condition a single supply to serve both
processor and servo successfully but, at least in early development, a
separate supply for heavy dynamic loads like servos and motors is a good
idea.

Tom
------------------------------------



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )