code for dual voltage 'window' on ADC input

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by medelec35 »

Hi Dave.
If there was any issues with timer interrupt etc then
All relevant messages will appear in the compiler message box.
What you are observing is nothing to do with code flashed to ur chip
When u say berserk at any point is led solid for 3 sec then off for another 3 secs
Also adding a 100 ufd cap should not cause prob you are describing. I again could be wrong but circuit sounds unstable
Since at the beginning of flowchart is a simple test which sounds like does not work.

Sent from phone
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by medelec35 »

daveb0360 wrote: Without the capacitance, using a scope, I see microscopic dips in the rail of 145uV during led 'on' times, nothing even close to what is needed to reset the pic, or affect measurements.
I have used a chip with very stable supply (confirmed with scope) using a voltage regulator, and it kept resetting until I added an electrolytic cap.
Then it stopped resetting.
It's also a good idea to have a 100nf as close to VDD and VS of chip.

Just a thought, what about disabling Brown out detection?

If it was was me, I would just concentrate on a simple flowchart that tests for resetting 1st.
E.g a like at the beginning of the latest flowchart:

LED on
delay 3 secs
LED off
Loop 3 times
Since that is not a random pattern, It should work every time power is 1st applied to your hardware
If that works then we need to look elsewhere.
If it's not working then either your hardware is as fault or Flowcode is bugged for 12F675
Martin

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by daveb0360 »

Hi Martin,
I sense you're getting as frustrated by this as I am and I'd quite understand if you 'walk away'.......In fact, it might be best cause I am now embarrassed that it's taking so much of your time.

I have a 1uF X7R ceramic cap, right on the supply pin of the micro, The PCB is based on ground plane for 0V as per standard practice. The supply goes unstable when a 47uF 'lytic cap is placed in same location (confirmed in simulation!) This doesn't concern me as it is perfectly stable without it.
With normal capacitance, as designed, the micro performs the test pattern flawlessly at switch on and never reverts or resets during operation.

I'm going to go and remove the regulation I have and replace it with a standard 7805 and try again. I hate to rule out anything but I have used this regulation circuit multiple times and also with pics before without issue. It's ultra stable, reference derived and comes straight from the datasheets so I have come to trust it. But, I am open to anything at this point and won't discount any cause.

I am thinking of starting from scratch and redefining a different micro or possibly just re-allocating the port pins.
In fact, I'm going to do this first. I never did like the idea of Vpp on a measurement pin!
So, I've studied the circuit and feel the following changes should improve matters in the hardware domain at least.
am going to test temperature on AN3 (pin 3)
Voltage on AN2 (pin5)
LED on GP5 (pin 2)
Mosfet drive to heater on GP0 (Pin7)

I'm starting to see validity in what you are saying about the possibility of buggy 675.........nothing else makes sense but let me try these hardware changes first to rule that out. (or in!?)

Dave

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by kersing »

daveb0360 wrote: I never did like the idea of Vpp on a measurement pin!
Dave,

You are aware the Vpp pin doubles as reset if not configured for I/O?

BTW in your diagram that pin is not used for measurement but connected to plus 5v via 100K.

Regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by medelec35 »

Hi dave, Would you like to try this file that is generated with V5
Still got solid 3secs on, then 3 secs off, then main starts.

Martin
Attachments
Water Heater 12F675 V2 +Test FC5.fcf
(34.01 KiB) Downloaded 339 times
Martin

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by daveb0360 »

Hi Martin,
Sorry but I can't use the FC5 file. I don't have and can't presently afford the full software and the free version won't allow the 675 or 617 chips...etc....etc.

Appreciate your efforts but I can't take that road at present.

FYI, I modified the hardware to use a 78L05 regulator and switched ports etc. but no difference whatsoever in the strange functioning of the LED. Once again, the temperature control loop works flawlessly as well as the voltage windowing.....it seems it's just the led patterns that are screwed up. :cry:

I don't know what step to take next... :?

Dave

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by daveb0360 »

kersing wrote:
daveb0360 wrote: I never did like the idea of Vpp on a measurement pin!
Dave,

You are aware the Vpp pin doubles as reset if not configured for I/O?

BTW in your diagram that pin is not used for measurement but connected to plus 5v via 100K.

Regards,

Jac

Hi Jac,
Now I feel very dumb.......I've been going round in circles with this for so long now, I lost focus on the schematic.
I opted initially to use internal reset feature but that gave programming issues..........chips were dying when programmed more than a few times...I don't know why but now I am just using internal BOD to do resets instead. Chip seems to reset OK this way and programming is no longer frying chips.

I don't think that resets are causing a problem. The basic control loops and ADC measurements seem to be fine, the program is functioning for the most part........it's just the various LED flash patterns indicating differing conditions and states, that is giving problems.

.....Lost..... :?

Dave

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by medelec35 »

daveb0360 wrote:Hi Martin,
Sorry but I can't use the FC5 file.
Oops Sorry was tired. I ment to post the V5 generated Hex file for you to try, not the flowchart :oops:
It has been a long day.

It may be worth using a 10K pull-up for MCLR or changing to internal. if only for elimination purposes.

Can you measure voltage directly in the pin of chip across ADC thats connected to thermistor while thermistor is at 42 degC


Martin
Attachments
Water Heater 12F675 V2 +Test FC5.hex
(4.38 KiB) Downloaded 298 times
Martin

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by daveb0360 »

Hi Martin,
Sorry this is making you so tired...truly.

I measured the voltage at adc pin when temp at 42C and it measures amazingly close to the predicted (calculated) value in the spreadsheet at 3.26V. Any error is probably my meter.

The led patterns displayed by this version are much closer to the required pattern ! I have posted another video. Crucially, they do not display the same instability of the previous versions and do not change when I switch to 3 differing VDD/Vref solutions. 1: Bench supply at 5V. 2: On-board TL431 derived supply (original) 3: On board 78L05 series regulator. So from this, I conclude that the inconsistency in the led flash patterns.....is not supply related or reset related.........This latter effect confirmed as the test patter at the front of the routine, does not re-appear at any point.

Supply voltage (Vref) is 5.001V on calibrated scope. 5.00 on my meter so there is no room for complaint here. The supply indicates a noise level of 210uV pk-pk and spectrum analysis puts the fundamental of the noise at approx 59Khz.......I think this can be ignored.

Clearly, there needs to be tweaks to the thermal accuracy but fundamentally, the thermal control works and shows no instability. It's on when required and off when required with no glitches or spurious activity inbetween.

My Mosfet output switch design is switching a 12 amp load with only a 12c rise in temperature and smooth operation so this is a success.

I don't understand much of the methodology surrounding the switching of the LED patterns so I can't lend much support my end but clearly, there is something not right. What I can say, is that because my real world led is active low pulled down from VDD and the code is written for active high, the patterns on the bench are inverted....not a major issue......just a little confusing.


Dave

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by medelec35 »

Hi Dave,
No it’s not this that’s making me tired, it’s my sleeping pattern.
Although I would like to see this working of course.
I did not take it in about pattern reversed, caused by LED active low, so I have altered that so LED is now active low :) .
I have made one more modification in the hope will cure the observeded randomness in LED patterns.

Martin
Attachments
Water Heater 12F675 V3.hex
(3.91 KiB) Downloaded 280 times
Martin

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times
Contact:

Re: code for dual voltage 'window' on ADC input

Post by daveb0360 »

Hi again.

I'm so sorry but this is no better.
Initially, at power up, supply below normal, led indicates intermittent pulses as required. Then, at supply increase to ~15V, (at the correct voltage for normal running,) Heater switches on, LED flashes even pulse absolutely correctly!
On reaching the 45c setpoint, led pattern switches to solidly on but with brief 'off' flash to indicate 'not stuck' as expected. However, there is a few seconds delay before the heater switches off resulting in uncontrolled overshoot of the setpoint. Heater should switch off immediately coincident with the solid on LED. From this point onwards, the led does not follow any predictable pattern of indication in any condition or state!

So sorry for this again....I'll upload another vid but it takes time to upload so will be a while.

Dave

Post Reply