DS18B20 with hpwm / pwmout with the 20X2 chip

ed1066

Member
I've been struggling with getting reliable readings from my DS18B20 sensors when I also have hpwm code.

I am running a variable speed pump based on temperature readings. I see from the manuals that the readtemp12 commands can interact with hpwm due to internal frequency changes and the manual suggested turning off pwm when doing readtemp commands. This isn't good and the pulsing pump isn't what I need.

I'm using the 20X2 chip on the AXE118 PICAXE-20 Project Board and I've tried adding some more capacitors as the Board has only one small capacitor .

I use this code

setfreq m4
hpwm pwmsingle, pwmHHHH, %1000, 249, w2

The setfreq m4 is an attempt to match the hpwm frequency with the 4MHz that readtemp uses.

The temperature readings are stable and correct when the pump is fully on or off, but at some intermediate duty values the temperature reading occasionally come in rogue - zero's or weird values. At a good intermediate duty maybe 1 in 1000 are rogue, while at bad points its been 1 in 2 or so.

I've tried changing the period and it changes the behaviour without solving the problem - i.e different duty settings give the problem.

It was all working fine with pwmout on a 18M2 chip and the CHI035 PICAXE-18 High Power Project Board, but I needed more memory for the program. For the output from the pin to the pump, I've reproduced the FET, diode, resistors, capacitor etc from the PICAXE-18 High Power Project Board on my new set up.
 

nick12ab

Senior Member
  • What capacitors?
  • The PWM speed is only changed if the PICAXE isn't running at 4MHz when the readtemp command is used
  • Can you use a lower PWM frequency?
 

ed1066

Member
  • What capacitors
The board has a CAP001 Decoupling Capacitor (100nF), I tried connecting another one direct to the +5V & 0V pins by physically jaming the wires just under the pins.
I also wired in a CAP002 Motor Capacitor (220nF) on leads from the board. No joy

  • Can you use a lower PWM frequency?
I tried all sorts of PWM frequencies. If it goes too low the motor pulses and beats, this upsets the chip even more and it resets during mid-program. I assume the pump motor has its own natural frequency and for stable operation the pwm frequency must be comfortably higher.
 

hippy

Ex-Staff (retired)
I tried all sorts of PWM frequencies. If it goes too low the motor pulses and beats, this upsets the chip even more and it resets during mid-program.
That does seem to suggest it's a noise issue or the power supply being collapsed under loading. Perhaps post a full circuit diagram then we can see exactly what you have.
 

ed1066

Member
That does seem to suggest it's a noise issue or the power supply being collapsed under loading. Perhaps post a full circuit diagram then we can see exactly what you have.
Thanks

I was disconnecting various other sensors etc to get the bare bones of a circuit wiith the problem .... and now the whole thing isn't working at all. I soldered the board in my pre-PACE training video days. (ref post http://www.picaxeforum.co.uk/showthread.php?22472-Soldering-up-the-LCD-and-OLED-kits&highlight=ed1066 ) So I think I'll start again fresh. I'll need to order more items from tech-supplies, so I won't be posting on this again for a few days.

Meanwhile, I suspect the issue might be related to the physical vibration from my pump motor exasperating another problem. Somewhere there is a voltage/current leak because the voltage regulator gets hot, but there are no obvious short circuits

Regarding maintaining voltage, what is best guidance on the capacitor sizes for circuits taking power like mine? Max current is 1.2A each through 2 FETs with 12V. The CHI035 PICAXE-18 High Power Project Board uses a 100nF and a what I believe to be a CAP006 Electrolytic Capacitor 100u in parallel across the +5V and ground. So I propose just to copy that. Is that a plan?

Cheers
 

westaust55

Moderator
If the voltage regulator is getting hot then might be worth you posting your schematic diagram for the entire circuit for folks here to review.
It could be rated to a large Vin to Vout differential with a relatively low current generating heat. Much mode than say 1 to 1.5 watts of heat/losses and a 7805 may need a heat sink.
 

westaust55

Moderator
If the PWM is interaction with the DS18B20 can you consider an 08M2 to read the temp as a sub module and use SEROUT to send the temp to the main PicAxe chip?
 

ed1066

Member
If the voltage regulator is getting hot then might be worth you posting your schematic diagram for the entire circuit for folks here to review.
It could be rated to a large Vin to Vout differential with a relatively low current generating heat. Much mode than say 1 to 1.5 watts of heat/losses and a 7805 may need a heat sink.
A1_cr.jpg

Here it is. My work on the Project board is shown in orange. The FET circuit I copied from my power board and linked across is in black because I don't know how to change its colour.

The supply is a 12V switched-power thingy - effectively a plug in phone charger
 

ed1066

Member
As I indicated, I re-made the circuit and that has resolved the problem. The voltage regulator stays at a normal temperature and the DS18B20's give reliable readings. So it seems the pump vibration may have set off a weakness in the circuit construction.

I still get very occasional mis-readings from one DS18B20 proble and I guess it's due to that probe having the longest lead and sharing the lead with the output to a display. Its a 4 core lead several metres long carrying: 5V, ground, a signal lead to the DS18B20 and a signal to the display.

So thanks for the help and suggestions

cheers

Ed
 
Top