does anyone know how to make the computer give commands to the basic atom telling it what to do?
I believe the serial port on the Bot board is for programming the Atom Chip. You create a basic program then load it onto the Atom via the serial port with the IDE program you can download on the Basic Micro website. Then the Atom reacts however you programmed it.
As far as I know, you can’t control the outputs ont he BotBoard in realtime from the serial port. I could be wrong though.
You could program the atom to coumunicate with the pc by using the programming port (bot board DB9) and a terminal program or your own VB program. Use SEROUT S_OUT, Baudrate, [Data]. This could be used to send data. Use SERIN S_IN for reciving. You have to have some knowladge of serial comunications to do this. I would also try a cheaper micro such as a PIC of SX chip.
I have not done this on the Atom, but I have done it on the Atom Pro. The code on the Atom would probably be very similar…
Somewhere in your main loop on the Atom you would have some code like:
[code] ;
; now lets try to get some serial input from our Host PC
;
serin s_in, i2400, 250, GCHTimeout, [sdec GHCCnt]
; Ok we got a count. If it is -1 then it is a do immediate!
if GHCCnt = -1 then
...
elseif GHCCnt = -2
...
endif
goto GCHMain
GCHTimeout
goto GchMain
[/code]
You would have code on the PC such as VB that could output what ever commands you need to output commands to your Atom. For example I have a VB program that outputs a couple of different commands to my brat. One function looks like:
[code] Private Sub Try1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Try1.Click
’ Send strings to a serial port.
Dim si As SEQ_ITEM
Using com1 As IO.Ports.SerialPort = _
My.Computer.Ports.OpenSerialPort(ComLB.Items(ComLB.SelectedIndex), BaudCB.Items(BaudCB.SelectedIndex))
com1.WriteLine(-1)
si = SEQS.Items.Item(SEQS.SelectedIndex)
com1.WriteLine(si.ToString)
End Using
End Sub[/code]
Good Luck
Dim si As SEQ_ITEM
but what did you define SEQ_ITEM as?
SEQ_ITEM is a private class that I use in my code to hold one Sequence Item. These sequences were setup so that I could generate or modify moves for the Brat. My Brat does not have an SSC32 hooked up and as such can not use SEQ to generate a new sequence.
The actual class definition is not that important here as the information that you would send between your PC and the Microcontroller will depend on what you decide you want for your command sequences. I only included the code fragment to show you a way to setup the serial communications.
Good Luck
oh,ok thank’s
i know what you are talking about now
i also want to know is , how do you tell the atom what position to put the servo when the program is running?
I am not sure what question you are asking here. I am using the Atom Pro for most of my fun.
If you are asking how do I program the atom Pro, to position the servos. On my Brat which has the servos connected to the AAB board, I use the HSERVO command, to tell the six servos where to go to next.
On my HEX which has the servos connected to a SSC32 board, I output serial text messages from the Atom Pro to the SSC32 board.
If what you are asking, is how do I determine what position to place each servo at, that is a much harder question to answer. This very much depends on what specifically you are trying to do with your robot. Once you know that, you can break down (decompose) the problem into smaller problems. You keep reiterating the decomposition until the problems are small enough for you to solve. There are whole classes and books that describe different ways of doing this.
For example if your question is that I would like I want to make my robot walk. Then you can start breaking this down into pieces, each of which may have several ways to solve it. For example the HEX program uses the inverse kinetic kinematics to calculate the position of each servo, while the Brat simply used canned sequences. It is easier to describe breaking down Brats walking into smaller pieces like:
Step forward
Step backward
turn left
turn right
go back to center
get up after falling forward
get up after falling backward
…
Then for each of the different small pieces you can use something like SEQ to generate a set of sequences with timing to accomplish that. This approach is what I was playing with on my Brat and where that code fragment that I posted earlier came from. Once you have these different sequences generated, you can add code to chain them togeather. For example Walk forward would be repeating the Step forward with a go back to center at the end…
Sorry I can not be more specific but again I am not sure what exactly you are asking for.
i meen like how do you tell the atom what to do with VB and not the BM editor?
now i have had some success in the past cause i made a program like some kind of test , it has two buttons on the computer screen and one says left the other ,right , when i pressed one it made the servo move
but now i changed it cause the servo would only move once and not agan
so i moddified the code that i made and now the servo dosn’t move ,period.
and i don’t have the previous code for it now so i cant show you it
but here is my new code:
Public Class SEQ_ITEM
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
' Send strings to a serial port.
Using com1 As IO.Ports.SerialPort = _
(My.Computer.Ports.OpenSerialPort("com1"))
com1.WriteLine(-1)
End Using
Catch ex As Exception
MsgBox("no signal")
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Using com1 As IO.Ports.SerialPort = _
(My.Computer.Ports.OpenSerialPort("com1"))
End Using
com1.WriteLine(2)
Catch ex As Exception
End Try
End Sub
Private Sub Comlb_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Comlb.SelectedIndexChanged
if comlb.Text = "com1" then _
End If
If Comlb.Text = "com2" Then
End If
End Sub
End Class
;variables
move var bit
right var word
right = -900
move = 1
left var word
left = 900
main
serin s_in,2400, move]
if move = (2) then
gosub s_left
endif
if move = (-1) then
gosub s_right
endif
s_left:
servo p0,left
servo p0,right
return
s_right:
servo p0,right
servo p0,left
return
goto main
I am in the process of switching from one machine (new one running vista) and I don’t have everything fully hooked up yet, so I can not help you fully debug your program.
But I will try to give you some ideas on what might be wrong or ideas on how to debug this.
-
On all of your Using com1 statements, you don’t pass a baud rate to the OpenSerialPort command. Now you might be lucky and your default baud rade for com1 is correct.
-
I am not fully sure in Button1_Click when the catch statement will be processed. I believe that the Using statement has an implied Try/Catch as part of it. In my code I have used the Try/Catch inside of a Using/ End Using code segment but not the other way around.
-
In Button2_Click, you have the com1.WriteLine outside of the Using/End Using and as such the WriteLine will probably not function.
-
the variable move is defined as a bit, so it can only be a zero or one. Try defining it as an SWORD
-
Maybe change the code on the atom side to something like:
Note: I put comments in each line that I changed…
[code];variables
move var sword ; hold a signed word
right var sword ; again a signed value
right = -900
move = 1
left var word ; Note: could simply put: left con 900
left = 900
main
serin s_in, i2400, 250, Tmeout, [sdec move] ; not sure about baudmode
if move = (2) then
gosub s_left
elseif move = (-1) ; changed for else if syntax to easily check errors
gosub s_right
else
endif
sound 9,[50\4400] ; Make a sound if you get some invalid input
goto main ; you want to check for input again and not fall into
Timeout
; maybe you want other stuff to happen
goto main
;subroutine code
s_left:
servo p0,left
servo p0,right
return
s_right:
servo p0,right
servo p0,left
return
[/code]
Again I do not remember if you are using an Atom or a pro and what the proper input parameter for your serin command should be. I am pretty sure it is not a straight 2400.
I hope this helps
yea, i made sure that i changed the baudrate property
but when i tryed using your program i get this:
Error: FILE C:\DOCUMENTS AND SETTINGS\BRANDON\MY DOCUMENTS\BASIC ATOM FIRMWARE.BAS(LINE 10) : [TOKEN ,] : Unexpected token type
and it has somthing to do with this:
serin s_in, i2400, 250, Tmeout, [sdec move] ; not sure about baudmode
i fixed a little typing error that said “tmout” you forgot the i in timout
but thats not the problem theres somthing else that im not sure about
oh yeah the baudrate is on 2400
As I stated in my post, I am not set up right now to debug this for you .
I believe I did mention that I was not sure about the parameters to the serin line. It depends on which IDE you are using, so try experimenting and see what works. Good Luck
ok its working now
i just have to debug it now and when im done i will tell you if it worked
thanks for the help
allright its not working now,
when i press a button it dosn’t move so whats the problem?
Figuring out what the problem is can be very fun. You need to try different things to see what is going on.
Are you receiving anything at the Atom board? Try adding a sound after the serin command to see if your program gets here. If it does try adding Serout commands on your atom board to see what you have received.
Try adding the baudrate of 2400 on your OpenSerialPort commands to make sure.
Try modifying your Atom code to maybe look at the buttons on the ABB board to see if your s_left and s_right commands are working. Maybe you don’t need or want two servo commands in each of these functions.
If you are not receiving anything at the atom card, put a breakpoint on the button handling routine on the PC and walk the code through to make sure the WritLine actually happens…
Good Luck
Kurte, is it possible to generate video with VB?
Sorry, But I do not understand the question . Maybe someone else might be able to answer this.
sorry, i meant ,is it possible to have a box on the software display a webcam
is there any objects that allow you to do this?