Hardware Recognition

fierojo

New Member
I'm having a little but of a problem with a new project in that I cannot load the new program.

Here are the details:

Picaxe: 18M2+
Programming Editor V5.4.0
Hardware: CHI035A
AXE027 Programming Cable

The Error Message I'm getting on the PC is:

The software is currently in the mode for PICAXE-18M2
The hardware connected to the computer is: Unknown

I'm running a dual core PC, Windows 7, 64 bit. Todate I've only been working with 8M2's.

Is the issue with the V5.4.0 software and the use of the PICAXE-18M2+?

Thanks.

Fierojo
 

fierojo

New Member
I downloaded V5,5 and that cured it, thanks.

Now I have another stupid question. How are the pins set for input and output, espectially when using the SR-04 ultrasonic sensor. It's essentially from the PICAXE site for the SR-05 sensor.

The "eyes" below refers to a set of LEDs on the front of a robot. The motion drive part of the program is not yet written. I'm workling on the generic and distance displays. The display (AXE133) works fine but is not displaying range.

My code is below:

#Picaxe 18M2
‘ ********************************************
‘ Display clear and initialization
Pause 500 ; initialization pause
serout c.7, N2400_4, (254,1) ; clear display
Pause 30 ; initialization pause
‘ ********************************************
‘ PICAXE-18M2 input/output pin definitions
symbol PingOut = C.0 ‘ Send out a Ping (output C.0)
symbol ReadPing = C.1 ‘ Read Ping back (input C.1)
‘ ********************************************
‘ Variables
Symbol Tm = W0
Symbol Range = W1
Symbol Repeat = W2
‘ ********************************************
‘ Text introduction
serout C.7,N2400_4, (254,1) ; clear display
Pause 50
serout C.7,N2400_4,(254,128,"Name of all Team members")
Pause 4000
serout C.7,N2400_4,(254,192,"How a Bat Sees")
Pause 3000
‘ ********************************************
‘ Ultrasonic Measurement and Conversion
main:
pulsout Pingout,1 ; produce 20uS trigger pulse
pulsin Readping,2,range ; measures the range in 10uS steps
pause 20 ; recharge period after ranging completes
let range = range * 10 / 148 ; Convert range to inches
debug range ; display range via debug command
serout C.7,N2400_4,(254,128,"Distance is")
serout C.7,N2400_4,(254,192,#range, "inches")
pause 2000 ; Delay so you can see the answer
low B.0 ; Turn on the eyes
pause 1000 ; Keep the eyes on for a second
high B.0 ; Turn off the eyes
pause 1000
goto main ; Do it again
 

westaust55

Moderator
Have a look/read about the DIRSx such as DIRSB or DIRSC which allow you to preset the direction of all pins for a port.
All pins are set as inouts on startup or reset.
Some commands such as HIGh and LOW will automatically set the direction for the specified pin to be an output.
 

fierojo

New Member
I'm getting to my wits end here. Hopefully I'm over looking something, but I'd appreciate a suggestions or two. This is where I'm at:

The main PCB is the AXE035A.
I'm using C.0 as the trigger, and C.1 as the echo.
C.7 is the LCD output (AXE133).
B.0, via a FET, is driving two LED's through a resistor.
I'm using 5 "AA" batteies for the project, I have the 78L05 installed on the AXE035A and the "shorting resistor" removed.

I'm using an HC SR-04 from E-Bay. It has 4 pins, trigger to C.0, Echo to C.1, Vcc to +5 on the 18M2+ side of the PCB, and ground

I also tried removing R7 and R8 from the AXE035a (10K pull down resistors). I get the same results with and witout the resistors

I've tried four different SR-04 sensors from three different soucres.

I've buzzed everything out and everything appears to be connected correctly. The PICAXE and sensor are getting 5.0 VDC

The 18M2+ programsd correctly based on the flashing LED's and correct text being displayed.

The readout I'm getting is always "0". This includes the "raw" read out on the LCD, the conversion to inches (obviously), and on the debug readout.

Is there something special about the SR-05 from Techsupplies?

The code I'm using is shown below:

#Picaxe 18M2
‘ ********************************************
‘ Display clear and initialization
serout C.7, N2400_4, (254,1) ; clear display
Pause 500 ; initialization pause
serout C.7, N2400_4, (254,1) ; clear display
Pause 50 ; initialization pause
‘ ********************************************
‘ PICAXE-18M2 input/output pin definitions
Symbol PingOut = C.0 ; Send out a Ping (output C.0)
Symbol ReadPing = C.1 ; Read Ping back (input C.1)
‘ ********************************************
‘ Variables
Symbol Range = W1
Symbol Repeat = W3
‘ ********************************************
‘ Text introduction
serout C.7,N2400_4, (254,1) ; clear display
Pause 50
serout C.7,N2400_4,(254,128,"Name of Team")
Pause 4000
serout C.7,N2400_4,(254,192,"How a Bat Sees")
Pause 3000
serout C.7,N2400_4, (254,1) ; clear display
‘ ********************************************
‘ Ultrasonic Measurement and Conversion
main:
pulsout Pingout,1 ; produce 20uS trigger pulse
pulsin Readping,2,range ; measures the range in 10uS steps
pause 20 ; recharge period after ranging completes
serout C.7,N2400_4,(254,128,#W0) ; display raw range
pause 2000 ;delay for raw display
serout C.7, N2400_4, (254,1) ; clear display
Pause 50 ; initialization pause
let range = range * 10 / 58 ; Convert range to inches
debug range ; display range via debug command
serout C.7,N2400_4,(254,128,"Wall distance is")
serout C.7,N2400_4,(254,192,#range, " inches" )
pause 2000 ; Delay so you can see the answer
low B.0 ; Turn on the eyes
pause 1000 ; Keep the eyes on for a second
high B.0 ; Turn off the eyes
pause 1000
goto main ; Do it again
 

hippy

Ex-Staff (retired)
Simplify the code to be the bare minimum -

Code:
#Picaxe 18M2
#Terminal 4800
Do
  PulsOut C.0, 1
  PulsIn C.1, 1, w0
  SerTxd( #w0, " " )
  Pause 1000
Loop
Do you have a link to the HC SR-04 datasheet ? Are you sure you have the trigger and echo pins round the right way ?

Have you searched the forum for other uses of the HC SR-04 ? I vaguely recall there may have been some issue with a fast response of the echo pulse which may require running at faster than the default 4MHz speed.

Do you have a Rev-Ed SRF005 to try ? Does that work ?

Do you have an oscilloscope or logic analyser which will let you check what is happening on the module's trigger and echo pins ? Is there any LED on the module which flashes or does not flash when you run the test programs ? What happens if you connect trigger but not echo ?
 

fierojo

New Member
Hi Hippy,

Thanks for the suggestions. The one involving your recollection of the PICAXE operating speed did it. When the 18M2+ was set to run at 8 MhZ, everything worked fine. I may have to modify the conversion to inch program, but I'll save that for tomorrow. My code now looks like this:

#Picaxe 18M2
setfreq m8
pause 10 ' Let PICAXE stabilize
‘ ********************************************
‘ Display clear and initialization
serout C.7, N2400_4, (254,1) ; clear display
Pause 500 ; initialization pause
serout C.7, N2400_4, (254,1) ; clear display
Pause 50 ; initialization pause
‘ ********************************************
‘ PICAXE-18M2 input/output pin definitions
Symbol PingOut = C.0 ; Send out a Ping (output C.0)
Symbol ReadPing = C.1 ; Read Ping back (input C.1)
‘ ********************************************
‘ Variables
Symbol Range = W1
Symbol Repeat = W3
‘ ********************************************
low C.0 'Assure C.0 is low to generate a high pulse

‘ Text introduction
serout C.7,N2400_8, (254,1) ; clear display
Pause 50
serout C.7,N2400_8,(254,128,"Name of Team")
Pause 4000
serout C.7,N2400_8,(254,192,"How a Bat Sees")
Pause 3000
serout C.7,N2400_8, (254,1) ; clear display
‘ ********************************************
‘ Ultrasonic Measurement and Conversion
main:
pulsout Pingout,1 ; produce 20uS trigger pulse
pulsin Readping,1,range ; measures the range in 10uS steps
pause 20 ; recharge period after ranging completes
serout C.7,N2400_8,(254,128,#W0) ; display raw range
pause 2000 ;delay for raw display
serout C.7, N2400_8, (254,1) ; clear display
Pause 50 ; initialization pause
let range = range * 10 / 148 ; Convert range to inches
debug range ; display range via debug command
serout C.7,N2400_8,(254,128,"Wall distance is")
serout C.7,N2400_8,(254,192,#range, " inches" )
pause 2000 ; Delay so you can see the answer
low B.0 ; Turn on the eyes
pause 1000 ; Keep the eyes on for a second
high B.0 ; Turn off the eyes
pause 1000
goto main ; Do it again

This does raise an interesting question though, why? Why did doubling the PICAXE clock solve the issue. One person who had a similar issue stated that his project worked fine on 8M2 with the SR-04, but would work when transfered on to a 14M2 (he is the guy you were refering to for the doubling of the clock). I was under the impression that the pause command as well as many others, were set to the base clock?

As for your other questions:

Do you have a link to the HC SR-04 datasheet? Are you sure you have the trigger and echo pins round the right way?

There is no real data sheet. The data sheet consists of the operating voltage, current, and pin definitions. The Trigger and Echo pins were/are wired correctly.

Have you searched the forum for other uses of the HC SR-04? I vaguely recall there may have been some issue with a fast response of the echo pulse which may require running at faster than the default 4MHz speed.

This is where the answer came from. I did a search yesterday and didn't get any worthwhile answers. Today three additional responses came up one involving the clock speed.

Do you have a Rev-Ed SRF005 to try? Does that work?

I ordered two yesterday, they were shipped today. I'm sure I'll find a use for them.

Do you have an oscilloscope or logic analyser which will let you check what is happening on the module's trigger and echo pins ? Is there any LED on the module which flashes or does not flash when you run the test programs ? What happens if you connect trigger but not echo ?

I used a slow scope yesterday. I did see the trigger on occaission but not the echo. I'm assuming its was the slow scope. There are no LEDs on the SR-04. I tried disconnecting the trigger and "ringing" keys to hopefully produce some type of resposnse, but nothing happened.

Thanks again for your suggestions.

Sincerely,

Fierojo
 

hippy

Ex-Staff (retired)
When the 18M2+ was set to run at 8 MhZ, everything worked fine ...
This does raise an interesting question though, why?
The HC SR-04 returns an echo pulse after being given a trigger pulse. Unfortunately the leading edge of the echo pulse comes back so soon after triggering that the PICAXE at 4MHz does not have time to get from its PULSOUT command into its PULSIN command so it cannot read the echo pulse.
 
Top