Jason, excellent project. I'll read your code and i'll give you my suggestions. Ricardo Callejo SURbyte Argentina ----- Original Message ----- From: jason rollette To: AVR-Chat@yahoogroups.com Sent: Thursday, June 15, 2006 12:02 PM Subject: [AVR-Chat] AVR as Controller for ROV Submarine I am new to this group, and am currently working on the program done for a MEGA32 to control a Remote Operated Vehicle Submarine. More details can be found here www.rollette.com/rovrev2 the program accepts serial commands from a laptop, and is controlled via a visual basic interface. See screen.jpg the interface sends the following command sets. Here are the serial commands from Visual Basic or HyperTerminal. The values are a lower case letter each followed by a value from 0-9 and a carriage return. Value "0" being off. a0-9 = Forward, b0-9 = Reverse, c0-9 = Left, d0-9 = Right, e0-9 = Up, f0-9 = Down, g = Ping, h = Air Lift, i = Torpedo, j = Aux1, k0-9 = ballast, l0-9 = Lights, m0-9 = IR lights, Commands received from processor: When the sub is first turned on it sends back "Ready" Commands are in UPPER CASE followed by a number in the range ex.: C56 means the compass is sending back a reading of 56 degrees. C Compass direction (in degrees) 1-360, L Leak message 0 = no leak, 1 = leak, P Pressure (in PSI) 0-500, TI Internal ROV temperature (in degrees Fahrenheit) 0-100, TW Water temperature (in degrees Fahrenheit) 0-100, V Battery Voltage 1-20, X -90 - +90 tilt angle(front to back vertical), Y -90 to +90 tilt angle(left to right horizontal). Attached is my program it is done in BASECOM. I do not have all the features working, like speed control, it is just on/off now. I am also unsure how to take an ADC and manipulate it with a multiplier. I am not sure what variable to define it as. I am also unsure how to have more than one "one wire" device. Any help or suggestions, or code modifications would be appreciated. Jason $regfile = "m32def.dat" $crystal = 10000000 Dim S As String * 2 Dim Letter As String * 1 Dim Number As String * 1 Dim Y As Word , X As Word , V As Word , P As Word , Ti As Word Dim Temp_buf As Byte , Stat_buf As Byte Enable Interrupts Config Adc = Single , Prescaler = Auto Config Portb = Output Config Pind.4 = Output Config Pind.5 = Output Config Pind.6 = Output Config Pind.2 = Input Config Pind.1 = Input Config 1wire = Pind.3 Config Serialin = Buffered , Size = 20 Config Serialout = Buffered , Size = 25 'setup the UART 'Portb = 0 Start Adc 1wreset 'Print Err ' optional 1wwrite &H0C ' write status 1wwrite &B01000010 V = 0 X = 0 Y = 0 P = 0 Print "Ready" Do 'begin the loop Program: 'Start Adc P = Getadc(3) V = Getadc(2) X = Getadc(0) Y = Getadc(1) Print "X" ; X Print "Y" ; Y Print "V" ; V 'scaler to according to voltage divider Print "P" ; P 'scaler to according to voltage divider 1wreset 1wwrite &HEE 1wreset 1wwrite &HAA ' get temperature Temp_buf = 1wread() 1wreset 1wwrite &HAC Stat_buf = 1wread() Print "TI" ; Temp_buf ; " " '; Stat_buf ; " " If Pind.1 = 1 Then Print "L1" End If If Pind.0 = 1 Then Print "L1" Else : Print "L0" End If 'get a char from the UART Input S Letter = Left(s , 1) Number = Right(s , 1) If Letter = "l" Then Select Case Number Case "0" : Portd.4 = 0 Case Is >= "1" : Portd.4 = 1 End Select Goto Program End If If Letter = "e" Then Select Case Number Case "0" : Portd.5 = 0 Case Is >= "1" : Portd.5 = 1 End Select Goto Program End If If Letter = "f" Then Select Case Number Case "0" : Portb.2 = 0 Case Is >= "1" : Portb.2 = 1 End Select Goto Program End If If Letter = "d" Then Select Case Number Case "0" : Portb.3 = 0 Case Is >= "1" : Portb.3 = 1 End Select Goto Program End If If Letter = "c" Then Select Case Number Case "0" : Portb.4 = 0 Case Is >= "1" : Portb.4 = 1 End Select Goto Program End If If Letter = "b" Then Select Case Number Case "0" : Portb.5 = 0 Case Is >= "1" : Portb.5 = 1 End Select Goto Program End If If Letter = "g" Then Pulseout Portd , 6 , 500000 Waitms 225 Pulseout Portd , 6 , 600000 Waitms 125 Pulseout Portd , 6 , 500000 Goto Program End If If Letter = "a" Then Select Case Number Case "0" : Portb.7 = 0 Case Is >= "1" : Portb.7 = 1 End Select Goto Program End If Loop __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com [Non-text portions of this message have been removed] [Non-text portions of this message have been removed]
Message
Re: [AVR-Chat] AVR as Controller for ROV Submarine
2006-06-16 by Ricardo Callejo
Attachments
- No local attachments were found for this message.