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 | Re: Com3 Vs. PulseOut -> Driving Servos

Discussion forum for the BasicX family of microcontroller chips.

Com3 Vs. PulseOut - Eric - Dec 27 12:22:00 2005

I'm working on a project where I'm trying to navigate a 4WD skid-steer
bot using data from a gps. I have a BX-24p in a Lynxmotion mini atom
bot board. Pin 20 is connected through a level shifter to the rs-232
interface of a handheld gps (Garmin Legend). The gps streams data in
standard 4800 81N nmea format over the serial link. I use com3 on pin
20 to read the serial data. (I'm using com3 and an arbitrary pin so I
can Debug.Pring info to com1.) I can read current lat/long/heading, I
have a waypoint in the BX and the BX calculates bearing to target,
compares to current heading and figures out which way to turn to head
towards the target. I've tested this much while carrying the gps and
board around while walking and it works.

However, I have now plugged the continuous rotation modified servos
from the bot into pin 7 and 8 and put in PulseOut commands to drive
the servos rather than just print "right," "left," or "forward."
Unfortunately, I'm now getting garbage data for lat/long/heading.
When I comment out the PulseOut command -- works. When I uncomment
PulseOut command -- garbage in.

I suspect that it is a timer conflict between com3 and PulseOut. The
manual says that there may be a conflict when using PulseOut and com3
at the same time. However, I'm only sending a 1.5 ms pulse each to 2
servos and while reading the serial data, I don't send any pulses at
all so it isn't like I'm using both at the exact same time. I have
the PulseOut in my main loop and I've thought about putting some extra
delay in. I've also thought about moving the gps input to com1 and
using com3 for debugging, but haven't done that yet as I think I'll
have to use more complicated serial calls rather than the simple
Debug.Print.

If anyone has experienced this before and can help, it would be much
appreciated. I can post code snippets if that would help.

Thanks,

Eric





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


Re: Com3 Vs. PulseOut - Tom Becker - Dec 27 18:07:00 2005

> ... it isn't like I'm using both at the exact same time.

Consider that COM3 is implemented in firmware, and is buffering input in
the queue ahead of your demand for it so, as long as the port is open,
it will be using Timer2.

A solution might be to close COM3 when you have a complete frame of GPS
data and open it again when you're ready for more. I suspect that the
CloseCom(3,...) will immediately free Timer2; it will also dump whatever
valid data remains in the input queue. You should be able to use
PulseOut with COM3 closed.

If that won't work or you lose too much data, you might need to move to
COM1. Tom





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

Re: Com3 Vs. PulseOut - Don Kinzer - Dec 27 18:18:00 2005

--- In basicx@basi..., "Eric" <aliasmrjones@y...> wrote:
> The manual says that there may be a conflict when using PulseOut
> and com3 at the same time. However, I'm only sending a 1.5 ms
> pulse each to 2 servos and while reading the serial data, I
> don't send any pulses at all so it isn't like I'm using both
> at the exact same time.

If Com3 is open you are, in fact, "using it".

The way that a software UART like Com3 works is that the processor
is interrupted at some multiple of the bit frequency - often 4 or
more times the bit rate but I don't know the particulars of the BX
implementation. The higher interrupt rate is required in order to
guarantee that each bit is sampled near the center of the bit's time
slot. The goal is to sample right at the 50% point in the bit
window but doing so somewhere in the 25% to 75% range will work as
long as the transmitter's and/or receiver's bit rate clocks are not
too far from the ideal frequency.

(Technical sidebar: It is important to remember that the A in UART
stands for asynchronous. Since the transmitter and receiver are not
synchronized except by detection of the start bit, a 4x multiplier
is about the smallest you could expect to successfully use under
conditions of worst-case clock skew between the transmitter and
receiver. Clock rate inaccuracies can add to the problem because
the timing difference accumulates with each bit in a character.
This causes the receiver to get further ahead of or behind the
transmitter for later bits in a given character.)

Assuming a 4x interrupt rate, at 4800 baud the BX is getting an
interrupt about every 52uS. If you have interrupts disabled for
more than about 1/4 of a bit time you run the risk of the software
UART getting out of sync with the bit stream and, consequently, not
sampling the input line at the right time or missing some bits
entirely.

If you call PulseOut with a pulse time of 1.5mS, interrupts will be
disabled for approximately 1.5mS. During that time you could miss 7
or 8 bits of the incoming serial data.

Even if you use the hardware UART (Com1) you'll have to be careful
using PulseOut and other routines that disable interrupts. The
longest that you can have interrupts disabled when using the
hardware UART is just short of two character times (but leaving
enough time for the processor to fetch two received characters). At
4800 8N1 there are 10 bits per character so you can keep interrupts
disabled for something like 4mS maximum and still avoid missing
incoming characters.





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

Re: Re: Com3 Vs. PulseOut - Paul Dubinsky - Dec 27 19:14:00 2005

Don Kinzer wrote:

> >...<
>
>Even if you use the hardware UART (Com1) you'll have to be careful
>using PulseOut and other routines that disable interrupts. The
>longest that you can have interrupts disabled when using the
>hardware UART is just short of two character times (but leaving
>enough time for the processor to fetch two received characters). At
>4800 8N1 there are 10 bits per character so you can keep interrupts
>disabled for something like 4mS maximum and still avoid missing
>incoming characters. I just finished a project with exactly this problem: that is, not having
enough time to process the data that was streaming from an RS-232 GPS
device. I'm using a Laipac G30 which is capable of transmitting either
NMEA protocol or SiRF protocol , either streamed or polled. The reason I
selected the Laipac was that it is capable of being polled. I don't now
if the Garmin Legend is capable of being polled, but if it is (if it's a
SiRF receiver, it probably is), you can stop the streaming data and only
get data when you want it by polling the receiver for it. That would
allow you to stop multitasking and get some control over the processing
stream.

I'm about to post some code that demonstrates how to stop the streaming
and poll for the sentences that you want. I'll get it up as soon as I
get out from under another software project. Oh yeah, Happy Holidays.
(Now where is that code that I'm looking for...)

Paul

ps. Warning: Off Topic. I saw the Miller commercial with the Christmas
light show. The very least they (Miller's advert agency) could have done
was credit someone other than themselves for the light show. THAT should
be covered under the Millenium Copyright Act!





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

Re: Light Show - Don Kinzer - Dec 27 19:32:00 2005

--- In basicx@basi..., Paul Dubinsky <pdubinsky@f...> wrote:
>... The very least they (Miller's advert agency) could have done
> was credit someone other than themselves for the light show.
> THAT should be covered under the Millenium Copyright Act!

Of course, what we don't know is whether they used it with permission -
they may have paid the creator handsomely for his work. If not,
it'll soon be Miller time for the him and his attorneys.

Don




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

Re: Re: Light Show - Paul Dubinsky - Dec 27 20:04:00 2005

Don Kinzer wrote:

>--- In basicx@basi..., Paul Dubinsky <pdubinsky@f...> wrote: >>... The very least they (Miller's advert agency) could have done
>>was credit someone other than themselves for the light show.
>>THAT should be covered under the Millenium Copyright Act!
>>
>>
>
>Of course, what we don't know is whether they used it with permission -
> they may have paid the creator handsomely for his work. If not,
>it'll soon be Miller time for the him and his attorneys.
>
>Don
Here's hoping. But I can here the lawyers arguing that it was in the
public domain ciruclating on the web just waiting to be salvaged by the
salvage pirates of Madison Avenue so they don't owe him a dime. Who
knows? We can only hope..

C8-) >Yahoo! Groups Links




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

Re: Com3 Vs. PulseOut -> Driving Servos - Eric - Dec 28 12:12:00 2005

Thanks for the replies. I changed my code a bit last night and I'm
not getting good lat/long/heading from the gps.

However, I'm now trying to drive my bot around...My bot is a 4WD
skid-steer using modified continuous rotation servos. I've peppered
my code with pulesout's, but I still can't get the servos to run
continuously.

So, I'm thinking about breaking my program up into 3 pieces with 2 and
3 being separate tasks that I'll spin off of my main program:

1. Main program - navigation and state control
2. Read com3 and decode lat/long/heading
3. Drive servos

So I'll continuously decode the gps data in the background and
continuously send pulses to the servos in the background and use the
main to compute which way to turn and change the values that pulseout
is sending.

My servo sub will be very simple --

pulseout to left servos
pulseout to right servos
sleep for 20 or 30 ms

I'm a bit concerned that the constant pulseouts will interrupt the
serial reads and I'll lose characters from the incoming gps data.
Does anyone see a problem with the above? The other option I've
thought of is to try to use the pwm output of the Atmega8535 to drive
the servos.




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

Re: Com3 Vs. PulseOut -> Driving Servos - arhodes19044 - Dec 28 13:35:00 2005

I used servo PWM with reasonable results. I then switched the
hardware an H-bridge and used PWM to drive the H-Bridge. It works,
but I think I need to figure out the optimal PWM frequency. I think
that the inductance of the motors interferes with the higher
frequency PWM rates.

I can hear a resonance "sing" in the motors at the high PWM rates, and
the torque of the motors drops to near zero.

-Tony





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

Re: Re: Com3 Vs. PulseOut -> Driving Servos - Tom Becker - Dec 28 14:25:00 2005

> ... The other option I've thought of is to try to use the PWM...

You can use PWM to drive servos, sure. As I recall, 28Hz and 56Hz are
available rates from dual-PWM Timer1. But, if you need to generate a
pulse period that can vary by 1mS (1.0mS to 2.0mS) at 56Hz (a ~18mS
period), you might suffer low useful PWM resolution.

If you use 10-bit Timer1 at 56Hz, (1/56/1024) ~= 17uS per PWM count, so
a nominal 1mS pulse width is represented by ~57 of the 1024 PWM counts.
Timer2, and thus COM3, will be unaffected. Tom





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

Parallax LCD display - Tim Chapman - Dec 29 2:20:00 2005

Has anyone been successful in sending data to the parallax LCD?

I get very intermittent results. Lots of garbage on the display.

Tim Chapman
tim@tim@...
TEC Computer Services
www.teccs.biz
(602) 486-0502

-----Original Message-----
From: basicx@basi... [mailto:basicx@basi...]On Behalf Of
arhodes19044
Sent: Wednesday, December 28, 2005 10:35 AM
To: basicx@basi...
Subject: [BasicX] Re: Com3 Vs. PulseOut -> Driving Servos I used servo PWM with reasonable results. I then switched the
hardware an H-bridge and used PWM to drive the H-Bridge. It works,
but I think I need to figure out the optimal PWM frequency. I think
that the inductance of the motors interferes with the higher
frequency PWM rates.

I can hear a resonance "sing" in the motors at the high PWM rates, and
the torque of the motors drops to near zero.

-Tony SPONSORED LINKS Microcontrollers Microprocessor Intel microprocessors
Pic microcontrollers ----------------------------------------------------------------------------
--
YAHOO! GROUPS LINKS

a.. ----------------------------------------------------------------------------
--
[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 )

Re: Parallax LCD display - arhodes19044 - Dec 29 9:37:00 2005

I have only used various brands of SERIAL interfaced LCD displays
(which have at their core a Hitachi parallel driver)

If you ever get any GOOD characters on your display, then the
technique you are using must be basically OK. Then the errors come
from either bad timing, noise, or electrical issues like pull-up/pull-
down resistors and the like.

How do you interface to that display? Pulse-out commands? Serial?
Parallel?

-Tony




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

Re: Parallax LCD display - wurlitzer28 - Dec 29 17:07:00 2005

--- In basicx@basi..., "Tim Chapman" <tim@t...> wrote:
>
> Has anyone been successful in sending data to the parallax LCD?
>
> I get very intermittent results. Lots of garbage on the display.
>
> Tim Chapman

This may not be even close to your problem but it is comm related. If
your system does work at times check for some noise.

I just spent 3 hours trying to figure out why my pipe organ
player/recorder stopped recording yet still played. The BX-24 was
sending garbage out but when the PC sent the data to the BX-24 in
playback it was fine. The clue was garbage data AND more important I
received more bytes than I expected.

It came down to the fact that I had moved the AC power cord from the
Dell laptop power supply to the multi-tap outlet in the organ and
noise from the power supply screwed up the BX-24 to PC transmission
at 38,400 baud. It worked ok if I lowered the baud rate to 19,200.
Moving the power cord to a wall outlet fixed the problem.

This laptop power supply and my Dell XP desktop PC both screw up my X-
10 system and some lights cannot be turned on if they are running.





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

Re: Re: Parallax LCD display - Paul Dubinsky - Dec 29 18:10:00 2005

Can you be more specific about the X10 problems and whatever solutions
you've found? My X10 system has one module that just seems to turn on
sporadically and I haven't been able to track down the source of the
problem.

I apologize for the OT'ness of this but this problem has really been
bedeviling me.

Thanks for your patience,
Paul wurlitzer28 wrote:

>--- In basicx@basi..., "Tim Chapman" <tim@t...> wrote: >>Has anyone been successful in sending data to the parallax LCD?
>>
>>I get very intermittent results. Lots of garbage on the display.
>>
>>Tim Chapman
>>
>>
>
>This may not be even close to your problem but it is comm related. If
>your system does work at times check for some noise.
>>...<
>This laptop power supply and my Dell XP desktop PC both screw up my X-
>10 system and some lights cannot be turned on if they are running. >
>
===================================================
"I've seen the future, and you're not going to like it."
-- Vincent van Gui
===================================================





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

RE: Re: Parallax LCD display - Tim Chapman - Dec 30 5:23:00 2005

Replying to all 3 who have responded to my inquiry:

Note that I am not using X10 to respond to Paul.

I am now getting the text sent to the serial port to show properly, but only
for a very brief time. This is what I am now trying to solve. Why doesn't
the text stay put on the display instead of disappearing?

Below is a copy of my code.

I have noticed that what I put as the next command after the Call
PutQueueStr(OutBuffer, "Hello World") line makes the display stay longer or
shorter times. It differs between as long as it takes you to blink once
versus twice. No significant changes. Any ideas?

Option Explicit

Public Sub SerialLCD()
' -----[
Variables ]----------------------------------------------------------

Dim InBuffer(1 to 30) As Byte
Dim OutBuffer(1 to 30) As Byte
Dim Tx as String * 1
' -----[
Initialization ]-----------------------------------------------------

Const SerialLCDPin As BYTE = 5
Const PiezoBuzzerPin AS BYTE = 6
Const LCDCommand AS BYTE = 22
Tx = Chr(65) ' Tx is "A" (ASCII 65)

' -----[ Main
Routine ]-------------------------------------------------------

FreqOut PiezoBuzzerPin, 3000, 0, 2000
Debug.Print "Open Queue"
Delay 1.0
Call OpenQueue(Inbuffer, 30)
Call OpenQueue(OutBuffer, 30)

Debug.Print "Define Com3"
Delay 1.0
Call DefineCom3(7, 5, bx0000_1000)

Debug.Print "Open Com3"
Delay 1.0
' Define baud rate and buffers for port 3.
Call OpenCom(3, 9600, InBuffer, OutBuffer)

Debug.Print "Send String"
Delay 1.0
'Output string.
Call PutQueueStr(OutBuffer, "Hello World")

Delay 5.0
Call PutPin(5,1)

Debug.Print "Close Com3"
Delay 1.0
Call CloseCom(3, InBuffer, OutBuffer)
Delay 1.0

Debug.Print "Done"

End Sub Tim Chapman
tim@tim@...
TEC Computer Services
www.teccs.biz
(602) 486-0502
-----Original Message-----
From: basicx@basi... [mailto:basicx@basi...]On Behalf Of
Paul Dubinsky
Sent: Thursday, December 29, 2005 3:10 PM
To: basicx@basi...
Subject: Re: [BasicX] Re: Parallax LCD display Can you be more specific about the X10 problems and whatever solutions
you've found? My X10 system has one module that just seems to turn on
sporadically and I haven't been able to track down the source of the
problem.

I apologize for the OT'ness of this but this problem has really been
bedeviling me.

Thanks for your patience,
Paul wurlitzer28 wrote:

>--- In basicx@basi..., "Tim Chapman" <tim@t...> wrote: >>Has anyone been successful in sending data to the parallax LCD?
>>
>>I get very intermittent results. Lots of garbage on the display.
>>
>>Tim Chapman
>>
>>
>
>This may not be even close to your problem but it is comm related. If
>your system does work at times check for some noise.
>>...<
>This laptop power supply and my Dell XP desktop PC both screw up my X-
>10 system and some lights cannot be turned on if they are running. >
>
===================================================
"I've seen the future, and you're not going to like it."
-- Vincent van Gui
=================================================== ----------------------------------------------------------------------------
--
YAHOO! GROUPS LINKS

a.. ----------------------------------------------------------------------------
--
[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 )

X10 problems - wurlitzer28 - Dec 30 12:53:00 2005

--- In basicx@basi..., Paul Dubinsky <pdubinsky@f...> wrote:
>
> Can you be more specific about the X10 problems and whatever
solutions
> you've found? My X10 system has one module that just seems to turn on
> sporadically and I haven't been able to track down the source of the
> problem.
>
All my X10 issues have been caused by the switching power supply of 2
computers.

If you experience intermittent problems with X10 try to determine if
anything is running when the problem occurs remembering that the power
supply on laptops will run with the laptop off. If you have a switching
power supply problem or other noise source, you can purchase a line
filter. That has helped me in the past, I just don't keep moving it
when I move my laptop so my X10 issues tend to reappear.

You also can have a problem if the remote receiver and the transmitter
are on opposite sides of the split 220/110 power line. X10 makes a
coupler to pass the signal from one side to the other.





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

Re: Parallax LCD display - pha555 - Dec 30 12:55:00 2005

--- In basicx@basi..., "Tim Chapman" <tim@t...> wrote:
>
> Replying to all 3 who have responded to my inquiry:
>
> Note that I am not using X10 to respond to Paul.
>
> I am now getting the text sent to the serial port to show properly,
but only
> for a very brief time. This is what I am now trying to solve. Why
doesn't
> the text stay put on the display instead of disappearing?
>
> Below is a copy of my code.
>
> I have noticed that what I put as the next command after the Call
> PutQueueStr(OutBuffer, "Hello World") line makes the display stay
longer or
> shorter times. It differs between as long as it takes you to blink once
> versus twice. No significant changes. Any ideas? There is another approach to using COM3 at

http://www.phanderson.com/lcd106/lcd107.html

Note that the commands sent to my design are different than for the
Parallax LCD, you might find the serial commands a bit simpler.

Note that this uses a project consisting of the LCD106a.bas and
Sercom3.bas.

P H Anderson, http://www.phanderson.com/basicx/




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

RE: Re: Parallax LCD display - Tim Chapman - Dec 31 1:53:00 2005

Hi P H,

In LCD106a, line 35 is:

Call SetupComPort(12, 9600, &H08) ' term 12, 9600 baud, inverted

There is no sub called SetupComPort. It is not in the system library or
SerCom3.bas.

Am I missing something here?
Tim Chapman
tim@tim@...
TEC Computer Services
www.teccs.biz
(602) 486-0502

-----Original Message-----
From: basicx@basi... [mailto:basicx@basi...]On Behalf Of
pha555
Sent: Friday, December 30, 2005 9:55 AM
To: basicx@basi...
Subject: [BasicX] Re: Parallax LCD display --- In basicx@basi..., "Tim Chapman" <tim@t...> wrote:
>
> Replying to all 3 who have responded to my inquiry:
>
> Note that I am not using X10 to respond to Paul.
>
> I am now getting the text sent to the serial port to show properly,
but only
> for a very brief time. This is what I am now trying to solve. Why
doesn't
> the text stay put on the display instead of disappearing?
>
> Below is a copy of my code.
>
> I have noticed that what I put as the next command after the Call
> PutQueueStr(OutBuffer, "Hello World") line makes the display stay
longer or
> shorter times. It differs between as long as it takes you to blink once
> versus twice. No significant changes. Any ideas? There is another approach to using COM3 at

http://www.phanderson.com/lcd106/lcd107.html

Note that the commands sent to my design are different than for the
Parallax LCD, you might find the serial commands a bit simpler.

Note that this uses a project consisting of the LCD106a.bas and
Sercom3.bas.

P H Anderson, http://www.phanderson.com/basicx/
[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 )

Re: Parallax LCD display - pha555 - Dec 31 9:31:00 2005

--- In basicx@basi..., "Tim Chapman" <tim@t...> wrote:
>
> Hi P H,
>
> In LCD106a, line 35 is:
>
> Call SetupComPort(12, 9600, &H08) ' term 12, 9600 baud, inverted
>
> There is no sub called SetupComPort. It is not in the system library or
> SerCom3.bas.
>
> Am I missing something here?
> Tim Chapman I have updated the file. Hopefully, correctly.

P H Anderson, http://www.phanderson.com/basicx/




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

RE: Re: Parallax LCD display - Tim Chapman - Dec 31 14:15:00 2005

Hi P A,

It sure seems to be my time to make silly mistakes. My batteries were low.
Time to set up monitoring of them.

Thanks for your help. My code worked. Your code works as well. I did not
take the time to remove the extra commands and stuff from your code so it
sends a lot of extra stuff to the display, but it works.

Thanks again for the help.

Tim Chapman
tim@tim@...
TEC Computer Services
www.teccs.biz
(602) 486-0502
-----Original Message-----
From: basicx@basi... [mailto:basicx@basi...]On Behalf Of
pha555
Sent: Saturday, December 31, 2005 6:31 AM
To: basicx@basi...
Subject: [BasicX] Re: Parallax LCD display --- In basicx@basi..., "Tim Chapman" <tim@t...> wrote:
>
> Hi P H,
>
> In LCD106a, line 35 is:
>
> Call SetupComPort(12, 9600, &H08) ' term 12, 9600 baud, inverted
>
> There is no sub called SetupComPort. It is not in the system library or
> SerCom3.bas.
>
> Am I missing something here?
> Tim Chapman I have updated the file. Hopefully, correctly.

P H Anderson, http://www.phanderson.com/basicx/
----------------------------------------------------------------------------
--
YAHOO! GROUPS LINKS

a.. ----------------------------------------------------------------------------
--
[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 )