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

Ads

Discussion Groups

Discussion Groups | BasicX | Problem Interfacing with MaxSonar EZ1

Discussion forum for the BasicX family of microcontroller chips.

Problem Interfacing with MaxSonar EZ1 - Nathaniel Barshay - Aug 2 11:21:32 2007

Hey,
I'm trying to interface a BasicX to a
MaxSonarEZ1,
and have been running into a rather annoying problem. Whenever I attempt to
request a pulse stream and the first data bits reach the BasicX, it resets
itself, or sometimes just freezes. I suspect that this could either be a
physical problem with current flow (although I don't get how such short
pulses could harm much), or it could be a problem with the incoming data
bytes overwriting some important memory space. My code is below,
Thanks for your help,
Nathaniel

'-----------------------------------------------------------------------------------------------------------------

Public SonarOQ(1 to 2) as byte 'Sonar Queues
Public SonarIQ(1 to 25) as byte
Public datain(1 to 10) as byte 'Dump data bytes from
queues here
Public erflag as boolean

Private TX as Byte 'Connected to serial
output of Sonar
Private RX as Byte 'connected to input of
sonar for requesting data

Sub Main()

Call OpenQueue(SonarOQ, 2)
Call OpenQueue(SonarIQ, 25)
Do

Call ClearQueue(SonarOQ) 'Clears the output queue
Call ClearQueue(SonarIQ) 'Clears the input queue
Call DefineCom3(TX, 0, bx0000_1000)
Call OpenCom(3, 9600, SonarIQ, SonarOQ)
Call PutPin(6, 1) 'Trigger read
cycle
Call Delay(0.01)
Call PutPin(6,0)
Call GetQueue(SonarIQ, DataIn, 5, 0.1, erflag)

'Program
never reaches this point with power to the sonar

Debug.Print cstr(erflag) 'Serial transmit a
success?

Call Delay(0.01)

Call CloseCom(3, SonarIQ, SonarOQ)

Loop
End Sub

'--------------------------------------------------------------------------------------------------------
[Non-text portions of this message have been removed]


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