Let's Make Robots!

Picaxe LCD Direct Connection Problem

Hey There,

I've hit a snag on a project of mine. I've been trying to build a servo calibrator (to test a servo's limits and test them on robots before they're connected to the motherboard) which should operate by positioning a servo depending on the position of a potentiometer, and display the pulse rate on a 16x2 LCD. I've built one before, with an LED display and a single servo output, but this one should handle two servos.

Except it doesn't. I won't even handle one.  There's two major problems I've found which I'm looking for solutions to.

This is my code (Picaxe 20M chip). I copied the three LCD routines from the manual, the rest is mine.

 init: gosub LCDinit

eeprom 0, ("  Servo 1:  Servo 2: ")

let b1 = 12

gosub wrins

let b1 = 1

gosub wrins

 

main: readadc 1, b8

readadc 2, b9

let b1 = 128

gosub wrins

for b3 = 0 to 10

read b3, b1

gosub wrchr

next b3

let b4 = b8

gosub servocal

let b1 = 192

gosub wrins

for b3 = 10 to 20

read b3, b1

gosub wrchr

next b3

let b4 = b9

gosub servocal

goto main

servocal: let b7 = b4 / 100

let b1 = b7 + 48

gosub wrchr

let b5 = b7 * 100

let b7 = b4 - b5 / 10

let b1 = b7 + 48

gosub wrchr

let b6 = b7 * 10

let b7 = b4 - b5 - b6

let b1 = b7 + 48

gosub wrchr

return

 

LCDinit: let pins = 0 'Clear all output lines 

let b4 = 0 'Reset variable b3 

pause 200 'Wait 200 ms for LCD to reset. 

let pins = 48 'Set to 8-bit operation. 

pulsout 3,1 'Send data by pulsing ‘enable’ 

pause 10 'Wait 10 ms 

pulsout 3,1 'Send data again 

pulsout 3,1 'Send data again 

let pins = 32 'Set to 4-bit operation. 

pulsout 3,1 'Send data. 

pulsout 3,1 'Send data again. 

let pins = 128 'Set to two line operation 

pulsout 3,1 'Send data. 

let b1 = 14 'Screen on, cursor on instruction 

gosub wrins 'Write instruction to LCD 

return 

wrchr: let pins = b1 & 240 'Mask the high nibble of b1 into b2. 

high 2 'Make sure RS is high 

pulsout 3,1 'Pulse the enable pin to send data. 

let b2 = b1 * 16 'Put low nibble of b1 into b2. 

let pins = b2 & 240 'Mask the high nibble of b2 

high 2 'Make sure RS is high 

pulsout 3,1 'Pulse enable pin to send data. 

return 

wrins: let pins = b1 & 240 'Mask the high nibble of b1 into b2. 

pulsout 3,1 'Pulse the enable pin to send data. 

let b2 = b1 * 16 'Put low nibble of b1 into b2. 

let pins = b2 & 240 'Mask the high nibble of b2 

pulsout 3,1 'Pulse enable pin to send data. 

high 2 'Back to character mode 

return 

Now my two problems.

#1: That code works fine when displaying the pot readings on the LCD, but you may notice that there's no servo commands in there. That's because as soon as I add anything on my servo out pins (0 and 1) the LCD freezes. It just goes blank. Remove the lines, and it works fine.

 #2: One of my pot inputs gives logarithmic readings. This is weird considering I have two linear pots. Any pot I put on Servo 1's input is log, any pot on Servo 2's input it linear. Swapping the pots around just proves it's nothing to do with them.

 So... this is my problem. Has anyone got any ideas? Thanks! 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Re-designed the PCB. Everything works now.

I finally have some code that doesn't interfere with the outputs, so that's one problem crossed off the list. However, even on a simple test I can't make the servos move; this is one of those frustrating things. I have a nice 5V supply to the servos from an independent (and heatsunk) regulator, which I used on my last tester. I'm using this code to test:

 main: readadc 1, b8

readadc 2, b9

servo 0, b9

servo 1, b8

goto main 

 

I think I can eliminate a code bug. I have a 360Ω resistor between the picaxe and the servo "pulse" pin, possibly too great for a significant signal to get through? I use the same resistors on the LCD lines, no problems there. Anyone else know of any potential issues?

 It is a resistor problem, I shorted the resistor with a bent paperclip and the servo worked. Ill pick up some lower values tomorrow from school and try to fix this thing... Also, my lead from the switch is almost snapped, so I need to track down a terminal block (I designed the PCB to use one) sometime. 

Repaired and functioning at 80%. Just need to fix a final issue and this should be good.

Download socket on the board broke, and I'm just swapping the chip between a programmer and my board until I find time to repair it. At least I can download again. Anyway, I've found the possible source of my troubles.

 The code I copied from the manual uses "let pins =" commands, which automatically set my servo pins to zero. I'm looking for an alternative that only interfaces the four outputs (4-7) that send data to the LCD, so the servo pins (0 and 1) are left alone. I have a possible solution, but I'm running out of code space; 256 bytes really isn't enough, and I don't have a supplier of the 20X2.

 Any Ideas? 

Current problem is the picaxe will not download, I'm leaning towards a faulty chip here after testing everything. No shorts, steady 4.95V supply and correct connection (it was working before!). I'll definitely pick up a spare tomorrow. 

Its powered by a single 12V battery. I split the supply using a 78L05 Regulator for a 5v 100mA supply for the LCD and Picaxe, and a heatsunk 7805 Regulator to supply 5V 1A to the servos. It's the same design I used on my first tester.
ezekiel181's picture

Your other one with a single servo works fine with the same code? I don`t know anything about basic so I wont try to comment on your code but..

Is there any load on the servos? With 2 loaded servos 1A could be close.

You have caps for ripple around the power supply and near the chip?

Perhaps it`s just a busted chip? Can you drop another one in to try?

Is the LCD backlight on? It may draw more than 100mA.  This one does.

If all else fails did you try modifying your other tester for a 2nd servo?

 

"Your other one with a single servo works fine with the same code? I don`t know anything about basic so I wont try to comment on your code but.."

I dismantled the old tester to save parts (and money) on the power supply circuit, as such that's not an option.
 
"Is there any load on the servos? With 2 loaded servos 1A could be close."
 
The servos aren't even plugged in. Just the addition of the servo code shuts it down.
 
"You have caps for ripple around the power supply and near the chip?"
 
Yep, two 100nF ceramics across the pins of each regulator, a 330uF across the 12V terminals, and a 100uF across the chip and LCD's 5V supply and ground.
 
"Perhaps it`s just a busted chip? Can you drop another one in to try?"
 
I can pick one up tomorrow, they're ridiculously cheap, and I want another for a future project anyway, as a slave serial LCD driver.

"Is the LCD backlight on? It may draw more than 100mA.  This one does."
 
Yes it is on, although as stated, it runs fine until the  servo commands are added. I use this module.
 
"If all else fails did you try modifying your other tester for a 2nd servo?"
 
The only problem with that was a lack of an extra output and input pin on the 08M chip on the old one. 
 
ezekiel181's picture
Whats your power supply? Is it only one for everything?