Error with ADC on 7 segm

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
maharadga
Posts: 71
Joined: Mon Dec 01, 2014 1:38 pm
Location: Bulgaria
Has thanked: 17 times
Been thanked: 12 times
Contact:

Error with ADC on 7 segm

Post by maharadga »

Hi all. I found error in my example. I use PIC16F876A, ADC on AN0 and boot 7- segment and LCD display.
Circuit is very simple. It work in Flowcode, but in Proteus don't. I don't see voltage in 7-segment. I see message: "ADC conversion started before "wait" time has expired following previous conversion or channel change".
I'm not sure what it's mean. It' my mistake or bug?
Somebody faced did with this?
Attachments
ADC_7segm_LCD.rar
(16.52 KiB) Downloaded 257 times
ADC_7segm_LCD.fcfx
(9.42 KiB) Downloaded 235 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Error with ADC on 7 segm

Post by QMESAR »

Hello
I had a quick look at your Flow chart I think you need to make sure you are caluculating the correct voltage value as your formula seems suspect to me :D

Any case The Error report you are getting in Proteus
This is just a warning message generated when a time less than a minimum of 2*TAd elapses between the start of a new conversion and old one or from the selection of a channel. You may get rid of this by possibly include a delay before setting the bit GO/DONE of the ADCON0 register. or you can disable the debug warning
All of this is actually cause by the way the boostC compiler or by Flowcode I am not sure which is calculating the minimum TAD incorrectly

To disable the debug warning go to

debug >> Configure Diagnostics >> PIC16F876A >> ADC Module and disable the warning in the Trace level
Attachments
1.jpg
1.jpg (74.03 KiB) Viewed 5486 times
2.jpg
2.jpg (48.52 KiB) Viewed 5486 times
3.jpg
3.jpg (55.94 KiB) Viewed 5486 times

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: Error with ADC on 7 segm

Post by medelec35 »

Hi maharadga,
QMESAR wrote:I had a quick look at your Flow chart I think you need to make sure you are caluculating the correct voltage value as your formula seems suspect to me
QMESAR is indeed correct.
If you're using Bytes or int then the maximum value allowed within a formula calculation is the highest and lowest value of signed 16bit e.g 32767
Taking your formula and an example:
volt = (ADC_Value * 5) * 100 / 255
if ADC = 255
then
255*5 = 1275 * 100 = 127500
At this point since number has exceeded 32767 then volt variable has rolled-over to so results will be wrong.

How about trying
volt = (ADC_Value * 49) / 25

Another issue would be if you have a 3 digit number like 411 then a two digit number like 12
then the result on your LCD will be 121 as the last digit will not have been cleared.
A way around this would be to place a

Code: Select all

print string "  "  
lcd component just after the

Code: Select all

print Volt
LCD component.

Martin
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: Error with ADC on 7 segm

Post by medelec35 »

I have modified your flowchart so it might work a bit better for you?

Martin
Attachments
ADC_7segm_LCD V2.fcfx
(10.88 KiB) Downloaded 269 times
Martin

maharadga
Posts: 71
Joined: Mon Dec 01, 2014 1:38 pm
Location: Bulgaria
Has thanked: 17 times
Been thanked: 12 times
Contact:

Re: Error with ADC on 7 segm

Post by maharadga »

My problem was that there was no evidence of indicators, only some features. In the actual design, however, the scheme works. Apparently not have much to trust the software because they are full of errors. I turn off warning messages, like QMESAR says. Also I don't now how make this: "... include a delay before setting the bit GO/DONE of the ADCON0 register ".
Thank medelec35 for calculations. They are not my strong point. :(
"Another issue would be if you have a 3 digit number like 411 then a two digit number like 12
then the result on your LCD will be 121 as the last digit will not have been cleared "... medelec35, you're absolutely right, but I have not had intended to view LCD. I turned him only to see what happens. it was important display is seven segment.
Now the scheme works.

maharadga
Posts: 71
Joined: Mon Dec 01, 2014 1:38 pm
Location: Bulgaria
Has thanked: 17 times
Been thanked: 12 times
Contact:

Re: Error with ADC on 7 segm

Post by maharadga »

I decided to try and module EBM003-thermistor with 7 segment. But again in Flowcode еverything works, in Proteus and real design not. In Proteus have noting, in real design display only 0 in last digit. I do not know if the error is related to the 7 segment or module 003-thermistor. Does anyone encountered this problem?
At first glance, ADC and EBM003-thermistor schematic are almost identical. Potentiometer input A0.
How can in ADC work, but in 003 don't? :?:
Attachments
Examples.rar
(36.67 KiB) Downloaded 271 times

maharadga
Posts: 71
Joined: Mon Dec 01, 2014 1:38 pm
Location: Bulgaria
Has thanked: 17 times
Been thanked: 12 times
Contact:

Re: Error with ADC on 7 segm

Post by maharadga »

I resolve it. It's my mistake.
Properties "Clock select" in Timer0 must be "internal clock".

Post Reply