A few problems: Flash Start up & IRQ

Started by chiefwigms November 21, 2003
Hey guys -

I'm having a couple problems with the 9S12DP256 and our robot.

First:
We have two DC motors wired to a SN754410 h-bridge (VCC1 is off of
the DP256, while VCC2 is off of an external battery pack), which is
wired from PWM pins on the DP256. Additionally we have a CMPS03
compass which uses I2C (its the only one on the I2C bus, with the
SCL and SDA lines having 5kohm pullup resistors) with VCC coming
from the DP256. We also have 2 radio-shack IR Emmitter/collector
devices wired (2 sets of line break sensors), that are powered via
an external battery pack (same as motors), with a 10k resistor
between VCC and collector, and a 300 ohm current limiting resistor
on the emmitter. The output of these line breaks gets buffered via
an HC541, and ALSO, the two inputs are NOR'd via an LS device, which
is then buffered through the HC541 chip (with a 10k pull up resistor
on the output of the LS NOR gate). The 2 outputs of the LS that are
buffered are then fed into port B, and the other output that is
buffered (from the NOR gate) is fed into IRQ on header 1 of the
DP256. Additionally we have an IR ranger (gp2y0a02yk) which uses
the A/D (we have a voltage divider with 200 and 300 ohm resistors,
to give Vrh +3V and Vrl 0V) and is externally powered (motor
batteries).

Our problem is: The compass works fine when running with the motors
on (same with the IR ranger). When we hook up the output of the
buffered NOR gate to IRQ, we constantly get interrupts even though
nothing is breaking the lines... If we disable the motors and leave
the same setup, the IRQ pin works fine (giving interrupts only when
any of the break-beams are broken)...

We tried isolating the power to the motors, and using a separate
power source for the IR ranger/Compass/Break beams, but the same
thing happens. We also hooked up the IRQ source (output from the
buffered NOR gate) to a oscilliscope and it reads normal (+5V when
nothing is breaking the lines, or 0V when something does break the
lines), and there doesn't appear to be a large amount of noise on
the line.

Any ideas why this would happen? And secondly:
We are using ICC12, and don't have too much code (just several files
which are included), and our s19 file is already 12K, reaching the
limits of the RAM. As a result we are looking at putting our
working code into flash, while running the test code in RAM (so we
don't have to jump everytime we want to load a small fix in the test
code). We were wondering if there is any startup routine we can
right in C to emulate the environment that DBUG12 establishes, ie
what clocks are set up, so that the code we write and test in DBug
12 is easily added to "flash code" which we know works.



> And secondly:
> We are using ICC12, and don't have too much code (just several files
> which are included), and our s19 file is already 12K, reaching the

If your S19 file is 12k, then the actual code should be less than 6k.
(An S19 file is text, and takes 2 characters for each actual byte of
code). Add to that the Sx, Address, databytes per line and the checksum
at the end, and your actual code is less than 50% of the S19 file.

John
http://embedded.mistekllc.com

> limits of the RAM. As a result we are looking at putting our
> working code into flash, while running the test code in RAM (so we
> don't have to jump everytime we want to load a small fix in the test
> code). We were wondering if there is any startup routine we can
> right in C to emulate the environment that DBUG12 establishes, ie
> what clocks are set up, so that the code we write and test in DBug
> 12 is easily added to "flash code" which we know works.




--- In , "chiefwigms" <chiefwigms@h...> wrote:
> Hey guys -
>
> I'm having a couple problems with the 9S12DP256 and our robot.

Without getting into the gory details of the design, motors have brushes, brushes make good spark gap transmitters.

You didn't forget to put snubbers on the brushes?

It will cause you all sorts of grief as well as failing the CE testing:-)

Cheers, Theo



We put cap's on between VCC and GND on the motors... Someone in the
tech-art message boards suggested putting a cap to ground on the 10k
pullup resistor of the LS device (and isolating motor ground from
microcontroller ground with an inductor)...

We'd still like to put our program into flash (even if it's 6k now,
there's alot more code that needs to be done), so any more advice is
welcome.

Thanks
-Pete

--- In , "theobee00" <yahoodump2@o...> wrote:
> --- In , "chiefwigms" <chiefwigms@h...>
wrote:
> > Hey guys -
> >
> > I'm having a couple problems with the 9S12DP256 and our robot.
>
> Without getting into the gory details of the design, motors have
brushes, brushes make good spark gap transmitters.
>
> You didn't forget to put snubbers on the brushes?
>
> It will cause you all sorts of grief as well as failing the CE
testing:-)
>
> Cheers, > Theo





At 05:40 PM 11/21/2003, Pete wrote:
>We put cap's on between VCC and GND on the motors... Someone in the
>tech-art message boards suggested putting a cap to ground on the 10k
>pullup resistor of the LS device (and isolating motor ground from
>microcontroller ground with an inductor)...

The old engineer's tale that I believe is put a 0.1 uF capacitor in series
with a 100 ohm resistor between the motor brush leads. Keep all the leads
as short as possible.

The brush arcs are negative resistors which allow any resonance around to
oscillate. You are trying to suppress microwave transmitters your scope
can't see.

(The 100 ohm resistor keeps the Q of any resonances of inductors with the
capacitor low, so you don't get ANOTHER resonance.)

Steve
*************************************************************************
Steve Russell mailto:
Senior Software Design Engineer http://www.nohau.com
Nohau Corporation phone: (408)866-1820 ext. 1873
51 East Campbell Avenue fax: (408)378-7869
Campbell, CA 95008
*************************************************************************


--- In , "chiefwigms" <chiefwigms@h...> wrote:

Hi Pete,

> We put cap's on between VCC and GND on the motors...

It's a start, snubber networks for motors need caps, Movs and inductors, all mounted right on top of the motor.
Earth layouts are critical, star config only, no loops.

Me? For PWM work I would put a couple of optos in, no connection to the CPU at all, even then you have to be careful with radiated noise.

>Someone in the
> tech-art message boards suggested putting a cap to ground on the 10k
> pullup resistor of the LS device (and isolating motor ground from
> microcontroller ground with an inductor)...

All little bits help in keeping the noise out, go opto, you have separate supplies anyway, cheaper, better.

The only time that is a problem is when you need to use tachos.
Even then you are probably better of to to go VCO and opto.

Also, if you can use CMOS for interface work instead of LS, (a lot slower), it will miss the real fast stuff all by itself, put a ten k or up in series to avoid damage and slow down a tad more.
Don't use 100k pulse rates from encoders of course:-)

I had some gadgets that had a Cmoss switch between the processor and a relay driver transistor, the transistor just had a 100 ohm between the coil and transistor to drop the voltage from 15V to 12 V, no diodes, snubbers, nothing.

Works fine, Back EMF was only 30-40V or so, transistor handles that fine.

Untill one day I put an LS chip in and sratched my head why my ultra reliable circuit all of a sudden blew transistors...

> We'd still like to put our program into flash (even if it's 6k now,
> there's alot more code that needs to be done), so any more advice is
> welcome.

Why, what is the problem?

Plenty of programs available that will burn your flash, I use Star at present, after some initial confusion about wich versions to use it has performed without fail.

Although I haven't implemented flash burning as yet, there should be no problem doing it serially.
Presently my program burns EEPROM serially and flash is much of a sameness, (got waylaid laying the board before Xmass shutdowns).

If you want examples, look for AN2153, it contains the buffered serial routines and relocatable flash burner. (You can't read the array while burning)

Took me a week of rolling my own before I found that, although my serial buffers worked fine, they had a nasty start/stop habit due to the way they handled XON/OFF, I didn't use interupts, after trying Motorolas I promptly archived mine:-)

It works well up to 19200 baud, after that the timing seems to be out too far, haven't had time to explore that as yet.

In addition in the files I have uploaded to here, there is some stuff I did in hurry up clunker code for EE burning.
Has the requirements for timing etc.

Just grab the bits you need and rebuild to your spec. Cheers, Theo