PICAXE 28X2 module and LDR fails ???

SolidWorksMagi

Senior Member
I copy/pasted the code from the page: http://www.picaxe.com/Circuit-Creator/Sensors/LDR-Light-Dependent-Resistor/

I'm using the circuit in the diagram with a 10KOhm resistor.

Using an 08M2 chip this works great!
main: readadc C.0, b1 ; read the value
debug ; show the value read
pause 1000 ; wait a short while
goto main ; repeat



Using a 28X2 chip this works great!
main: readadc A.0, b1 ; read the value
debug ; show the value read
pause 1000 ; wait a short while
goto main ; repeat

All I did was change the download cable from the AXE091 board to the PICAXE 28X2 module and connected the V+, Gnd and circuit to the A.0 pin and it fails!
 

oracacle

Senior Member
gonna need a bit more, how is it failing? can we have some pictures? which download lead are you using?
 

inglewoodpete

Senior Member
From what you are saying, it is clear that there is either a hardware or software error (fault). You need to diagnose the problem.

Start with the hardware. With the supply connected across the chip and the LDR/resistor circuit, what voltage do you measure (multimeter required) between:
  1. 0v pins (legs 8 & 19) of the 28X2 and the Vcc pin (leg 20)?
  2. 0v side of the divider resistor and the Vcc side of the LDR?
  3. 0v pins (legs 8 & 19) of the 28X2 and the Vcc side of the LDR?
  4. 0v side of the divider resistor and the Vcc pin (leg 20) of the 28X2?
  5. Finally, check that the voltage (relative to 0v rail) on pin A.0 varies according to the light level hitting the LDR.
Once you prove that the hardware is behaving as expected, you can move on to your software. Start by reading the command description for the ReadADC command, particularly in relation with X2 devices.
 

SolidWorksMagi

Senior Member
I'm using the AXE027 download cable.

I moved it from the AXE091 development board to the PICAXE 28X2 module.

I moved the jumper wires from the AXE091 development board to the PICAXE 28X2 module.

The circuit components remain the same in place on the AXE091 development board.

The only difference is the PICAXE 28X2 modules A.0 doesn't seem to work the same as the A.0 on the 28X2 chip.

The software is exactly the same on both the 28X2 chip as the 28X2 module.

I did try A.1, A.2 and A.3 on the PICAXE 28X2 module too and got the same failing results.

Moving the jumper wires and download cable back to the 28X2 chip on the AXE091 board the circuit and software work perfectly!
 
Last edited:

hippy

Technical Support
Staff member
The only difference is the PICAXE 28X2 modules A.0 doesn't seem to work the same as the A.0 on the 28X2 chip ... I did try A.1, A.2 and A.3 on the PICAXE 28X2 module too and got the same failing results.
What actual 'result' did you get ? Have you tried using other B.x or C.x pins ? Have you tried pulling the pin being used up to +5V via a resistor to verify those are providing high readings ?

It would be worth posting a photo of how things are with your wiring shown in case there is some oversignt in that respect.

It may be better to start with a test program which uses SERTXD rather than DEBUG, something like -

Code:
#Picaxe 28X2
#Terminal 9600
Pause 2000
SerTxd( "Starting ...", CR, LF )
Do
  ReadAdc A.0, b0
  SerTxd( "ADC reading = ", #b0, CR, LF )
  Pause 1000
Loop
 

stan74

Senior Member
28x2 needs a 1K pullup on pin 1 ?
Don't leave pins floating.
start:
b0=pinsa
sertxd (#b0,cr,lf)
goto start
You would expexct 0's but you get odd values if wires are connected..noise?
 

inglewoodpete

Senior Member
The only difference is the PICAXE 28X2 modules A.0 doesn't seem to work the same as the A.0 on the 28X2 chip.

The software is exactly the same on both the 28X2 chip as the 28X2 module.

I did try A.1, A.2 and A.3 on the PICAXE 28X2 module too and got the same failing results.

Moving the jumper wires and download cable back to the 28X2 chip on the AXE091 board the circuit and software work perfectly!
We know that the 28X2 on the AXE091 works now (it wasn't clear to me when I posted in #3)

Have you read the pinout details for the AXE201 module from manual 1? Are you connecting the LDR/Resistor to the correct pin?
 

hippy

Technical Support
Staff member
28x2 needs a 1K pullup on pin 1 ?
The AXE091 and AXE201 module have pull-ups fitted for the reset signal on leg 1 of the 28X2. We would recommend 4K7 pull-ups where these are added by a user.

Don't leave pins floating.
Floating pins are usually not a problem for PICAXE devices when those pins are not being used by the program code.
 

stan74

Senior Member
I left pull down resistors out and wondered why switches seemed pressed and pulled high but the chip was a crystal radio.
 

SolidWorksMagi

Senior Member
Hi,

On the PICAXE 28X2 module the reading at b0 in the Debug window floats 10-15 with or without light on the LDR.

On the PICAXE 28X2 chip the reading at b0 in the Debug window starts at 160 in nominal light to 237 when I shine a small flashlight on the LDR. The PICAXE 28X2 chip accurately tracks as the light gets brighter or dimmer.

On the PICAXE 28X2 module there is no change on b0 ... it just sits there floating between 10-15 as I move light on and off the LDR.

I did try C.0 pin on the PICAXE 28X2 module too ... same bad results.

[I tried to upload two photos from my PC and from my website but the [PICAXE server is getting errors writing a temporary file."]

Here are the two photos showing the circuit ...

First is the LDR on the AXE091 breadboard ... you can see the yellow (signal) wire that I switch from the PICAXE 28X2 chip to the PICAXE 28X2 module along with the AXE027 download cable.
http://brainless.org/MultiMedia/Pictures/IMG_6206-20170209-LDR-Wiring-c1K.JPG

Here you can see my PICAXE 28X2 module mounted on a RoboGuts circuit board ... I have +V and Gnd jumpered from the AXE091 and I use the yellow (signal) jumper too.
http://brainless.org/MultiMedia/Pictures/IMG_6207-20170209-LDR-Wiring-c1K.JPG

The wiring is simple exactly as the schematic on the PICAXE page: http://www.picaxe.com/Circuit-Creator/Sensors/LDR-Light-Dependent-Resistor/
I use a 10K Ohm resistor for the pull-up resistor.

I'm using the exact same program only changing the pin to A.0 for the PICAXE 28X2 chip and module.

On the PICAXE 28X2 chip this works perfectly! On the PICAXE 28X2 module it fails.


As for using the correct pins on the PICAXE 28X2 module ... I used PIN 13 = A.0 and also tried PIN 14 = A.1, PIN 16 = A.2, PIN 15 = A.3, PIN 5 = C.0 ...
 
Last edited:

hippy

Technical Support
Staff member
It sounds like there may be some inadvertent potential divider being created, perhaps pull-up and pull-down resistors being applied to the LDR input.

We would recommend putting the 28X2 module directly on breadboard and disconnecting the LED and all other connections which are not required to test the LDR.

It might be worth placing the RoboGuts board on a piece of paper, or something other than what looks like an electrostatic bag which may be conductive to some some degree,
 

SolidWorksMagi

Senior Member
Hi,

It's so important to have good jumper wires. After disassembling and reassembling the entire RoboGuts circuit it now works. Turns out one of the jumper wires on the board was bad.

Things like this can get so frustrating at times. But the lesson here was rebuild the circuit with different jumper wires sometimes.
 
Top