40X2 Pulsout not working correctly

Jack Burns

New Member
Pulsout is NOT working as expected on a 40X2.
I have discovered it causes more than one pin to change state at the same time, but only under certain conditions.

Looking at the waveforms below, the 'RS' line should NOT be pulsing, however when it's set high (high RS) then any pulsing on the 'EN' line causes 'RS' to change state at the same time. However, when RS is set low (low RS), then pulsing 'EN' has no effect on RS (which is the correct behaviour).

I'm not looking for a solution as using high/low commands or toggle on 'EN' seems to work correctly on the main project, however I would like to know if this a known problem with pulsout?

PICAXE Editor 6.1.0.0
40x2 Firmware vB.3
40X2 Compiler v3.4

Regards
Jack

25419


Here is some test code used to generate the waveforms.
Rich (BB code):
#REM

CODE TO DEMONSTARTE PROBLEM WITH RS LINE CHANGING STATE WHEN IT SHOULDN'T.
==========================================================================

Problem occurs with 'RS' normally high and 'EN' normally low.  Pulsing 'EN'
high causes 'RS' to go low for the length of the pulse on 'EN'.
This should NOT happen.

40x2 Firmware vB.3
40X2 Compiler v3.4
PICAXE Editor 6.1.0.0

#ENDREM

#picaxe 40x2
#no_table

symbol RS = A.7
symbol EN = A.6

low EN

; SEND PULSES USING PULSOUT
low RS
gosub sendPulse ' Works correct with RS low
high RS
gosub sendPulse ' PROBLEM WITH RS, SHOULD STAY HIGH.
low RS
gosub sendPulse ' Works correct with RS low

do : loop
end

sendPulse:
  for b0 = 1 to 10
    pulsout EN,100
    pause 10
  next b0
  return
 

Goeytex

Senior Member
Is the display connected when you test with the above code? Try with it disconnected.
I would also use a scope instead of the logic analyzer to see the actual voltage levels on the pin.

Maybe try (temporarily) moving RS to pin on PORTC and see what happens.

My guess is that this is not firmware related but something to do with the hardware.
 

Jack Burns

New Member
Geoytex, thanks for your reply.

This still seems to be a firmware problem as I have just tested a bare 40X2 with the logic analyser and still get the same output. I then connected 2 LEDs and modified the code to give longer pulses and the problem can be clearly seen on the LEDs.

New test code below.

Regards
Jack

Rich (BB code):
#picaxe 40x2
#no_table

symbol LED2 = A.7
symbol LED1 = A.6


low LED1

; SEND PULSES USING PULSOUT
low LED2
gosub sendPulse ' Works correct with LED2 low
high LED2
gosub sendPulse ' PROBLEM WITH LED2, SHOULD STAY HIGH.
low LED2
gosub sendPulse ' Works correct with LED2 low

do : loop
end

sendPulse:
  for b0 = 1 to 10
    pulsout LED1,50000
    pause 500
  next b0
  return
 

oracacle

Senior Member
Just to check things can you alter your sub procedure so that it doesn't use pulse out, instead:
Code:
High led1
Pause x
Low led1
Where X is the the pulse duration.
 

Goeytex

Senior Member
Picaxe firmware "remaps" these pins, meaning that the Picaxe defined PORTA is not the PIC Hardware PORTA. It is rather a software defined Port. So Picaxe A.6 and A.7 are actually on PIC hardwear PortE.

What you are seeing could be a glitch in the firmware, but I would think that would have been seen long before now.

Since these Picaxe pins are on physical PortE, it could be that this Port on the Chip has been damaged. Many times if an I/0 has been damaged the Picaxe will draw 15 to 50ma with nothing connected to any of the pins. Normally this would be around 2-5ma.

Suggest you test using A.4 And A.5 for EN and RS. These pins are on physical PortA rather than PortE.

AND ... as Oracacle suggested, eliminating pulseout might rule out a problem with the pulsout command itself.
 
Last edited:

Jack Burns

New Member
Oracacle and Geoytex, yes using high and low was the first thing I tried after discovering the problem and that worked perfectly, so I will continue to use that and eliminate pulsout on the current project.

Geoytex thanks for the remap info.
 

hippy

Technical Support
Staff member
This still seems to be a firmware problem as I have just tested a bare 40X2 with the logic analyser and still get the same output.
Good news and bad news in equal measure - I am seeing the same on my 40X2.

I would therefore guess this is some kind of firmware issue which hadn't been caught during testing which no one has experienced in all those years since launch.

Please accept our apologies if it is the case. The work round, as you have found, is to use a HIGH then LOW sequence. This will give an approximate 285us pulse at 8MHz.

The issue seems related to Port A only - and only for specific pins, A.5, A.6 and A.7 - though I haven't extensively tested every combination yet.

What you are seeing could be a glitch in the firmware, but I would think that would have been seen long before now.
It never ceases to surprise me how issues - and not just the few we have had - can go undetected for so long. When they are revealed it's hard to believe no one else had encountered the issue earlier, that it wasn't caught in testing. This one seems to have remained undetected for over a decade.

When it comes to testing it's simply not possible to test every combination there could be and sometimes things slip through the net. In this case I would guess it was tested by sequentially putting a PULSOUT on every pin of every port and checking that worked, failed to fully check what happened with other pins which were high.

I have to put my hands up to that failing as I was almost certainly the one doing the testing. I am sure I tested that PULSOUT does pulse high and low, but failed to spot the interaction which has now become obvious.

As for no one else running into the issue, I guess that's a combination of fewer people using 40-pin chips and none of those having a HIGH and a PULSOUT operating on the specific pins which reveal the issue.

Picaxe firmware "remaps" these pins, meaning that the Picaxe defined PORTA is not the PIC Hardware PORTA. It is rather a software defined Port. So Picaxe A.6 and A.7 are actually on PIC hardwear PortE.
It does seem to me that the port mapping for PULSOUT when using A.5, A.6 or A.7 is at the root of the problem. My guess would be some masking issue which is forcing the other pins low when pulsed high. That doesn't matter when the other is low but creates the low going pulse when high.
 

Aries

New Member
Have you tried your original setup with a different 40X2? I have (only once) had a similar problem with a 20M2 - sending serial data out on one pin caused an adjacent pin to "flicker". Changing the 20M2 for another one solved the problem, so I decided it was a faulty chip.
 

Goeytex

Senior Member
@hippy

If this is indeed a firmware bug, it may be prudent to also test the 28X2 for a similar issue. Probably nothing but won't hurt to test.
 

hippy

Technical Support
Staff member
The 28X2 doesn't have A.5-A.7 and there is no RE port for that silicon, so, given everything seems fine on A.0-A.4 on the 40X2, it should likewise be okay on the 28X2.

But, there is a pin mapping of A.0-A.3 -> RA0-RA3, then A.4 -> RA5, so I will test that

And : There's a bummer. It appears setting all A.0-A.4 high, PULSOUT pulsing A.0 through A.3 low also pulses A.4 low, pulsing A.4 low doesn't do anything.

So it seems a similar but slightly different masking issue which only manifests itself in particular circumstances. That these are far less likely than others where things do work as expected is probably how that escaped being revealed.
 
Last edited:

Jack Burns

New Member
Thanks to everyone that replied.
Aries I only have the one 40X2 so can’t try another one to see if it behaves differently, however Hippy experienced the same result (plus some other anomaly’s) so I doubt another would be any different. Good suggestion though :).
 
Top