getting outputs from sensor into PIC16F690 LCD

Moderator: Benj

Post Reply
Jocelyn
Flowcode v5 User
Posts: 15
Joined: Thu Jan 31, 2013 11:38 am
Has thanked: 2 times
Contact:

getting outputs from sensor into PIC16F690 LCD

Post by Jocelyn »

Hi,
I'm new in Flowcode, I'm trying to build a program to get analog output of sensor to digital input of PIC and this digital value will be shown on a virtual LCD display in program. My problem is how should I interface/read the analog outputs from sensor into my program. The virtual LCD display should show the digital input value. It'd be appreciated if someone could help on this. :)
Attachments
16f690.fcf
getting outputs from sensor into PIC16F690 LCD-Flowcode v5
(12 KiB) Downloaded 271 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: getting outputs from sensor into PIC16F690 LCD

Post by medelec35 »

Hi Jocelyn,
Welcome to the forum and to Flowcode
There is a decimal to binary converter Flowchart here:
http://www.matrixmultimedia.com/mmforum ... 45&#p34995
The input variable would be the bytes read from ADC component.
So you can just merge the flowcharts together.

Hint how I would merge all the icons and variables:
1)Add a new Macro (Macro, New.. Menu) to Decimal to binary flowchart and name it.
2 Copy the conversion routine to the newly created macro.
3) Export the new macro (Macro, Export.. Menu)
4) Import this new macro (Macro, Import.. Menu) to your 16F690.fcf Flowchart.
Now you can cut and paste the Dec to Bin routine within your 16F690.fcf Flowchart.

If you get stuck, I can help you further by merging them for you.
Martin
Martin

Jocelyn
Flowcode v5 User
Posts: 15
Joined: Thu Jan 31, 2013 11:38 am
Has thanked: 2 times
Contact:

Re: getting outputs from sensor into PIC16F690 LCD

Post by Jocelyn »

Hi Martin,

So sorry , i guess i get you the wrong meaning, extremely sorry for the word mistake used. I should have decimal reading display on my virtual LCD. I need my program to read/interface the Voltages through sensor equipment(like Thermistor, Temperature sensor, Strain gauge, CdS sensor, etc) and display the Voltages in decimal on the virtual LCD. Is there any icon to use in program to probe the measurement or any that you would suggest?

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: getting outputs from sensor into PIC16F690 LCD

Post by kersing »

To read measurements from analog sensors, use ADC component.
“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: getting outputs from sensor into PIC16F690 LCD

Post by medelec35 »

No problem, I could of just as easily misinterpreted what you was asking.

I still a bit confused.

In your flowchart you have got the LCD to display voltage from 0 to 5V using ADC component. That is one thing your asking to do?
You have also got some LED's connected in parallel with LCD so if enabled line is not reset to 0 just before outputting to LEDs on port C, there will be corruption data on LCD.

So I'm guessing you want the LED to act like a LED linear analogue display (similar to using a LM3914 to drive LEDs)?
If so I can help you with that.
If not can you try and give as much detail as possible please since you have not mentioned LED's

I would also recommend removing the Display Clear and replace with Display Cursor x=0 y=0

Then as the last icon you could have a delay = 100ms so LCD is not asked to refresh too fast.

Martin
Martin

Jocelyn
Flowcode v5 User
Posts: 15
Joined: Thu Jan 31, 2013 11:38 am
Has thanked: 2 times
Contact:

Re: getting outputs from sensor into PIC16F690 LCD

Post by Jocelyn »

Actually I’m trying to apply the ADC conversion formula on page 93-94 in PICDEM Lab Flowcode : http://ww1.microchip.com/downloads/en/D ... 41381B.pdf

ADC here is to allow conversion of an analog input voltage by comparing it to a reference voltage of 5V. With ADC, analog input from sensor to microcontroller converts to 8 bit digital number with low voltage reference (Vref-) 0v and high voltage reference (Vref+) 5V. The output is displayed using 8 LEDs that show the binary form representation of the voltage level in digital values.
This means when,
Voltage thru sensor(this could be monitored using DMM) is 0V = LEDs will show 0000 0000 (binary representation of ADC value)
And this do up all for inputs before reaching the maximum 5V = 1111 1111 show on LEDs. (Voltages is varied within 0V to 5V since it’s compared against the VDD voltage, 5V internally.)
Further Example :
LED output = 01010110
1/2 Vdd 1/4 Vdd 1/8 Vdd 1/16 Vdd 1/32 Vdd 1/64 Vdd 1/128 Vdd 1/256 Vdd
0 1 0 1 0 1 1 0
8 bit LED ADC Results = 1/4 Vdd + 1/16 Vdd + 1/64 Vdd + 1/128 Vdd
= ( 1/4 + 1/16 + 1/64 + 1/128 )×Vdd
= ( 1/4 + 1/16 + 1/64 + 1/128 )×5V
= 1.68 V (Approximate value shows on DMM and should be displayed on virtual LCD panel)

As sensor hardware is connected to RB4/AN10 pin of pic16f690 should then light the LEDs sequentially in an binary fashion representing the ADC result value.
Then, either using the ADC conversion formula to convert the binary value to decimal value or any other possible method to display decimal value on LCD.

My difficulty now is that program doesn’t read/interface any data/readings into my program. Once Voltage thru sensor hardware is probed, virtual LCD should display the decimal Voltage value, instead of manually adjusting the ADC component to display some value as of now. Some interface within the program is needed.

Hope that you could get some idea on this and free to ask for any further clarification. Thanks.

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: getting outputs from sensor into PIC16F690 LCD

Post by medelec35 »

Jocelyn wrote:Actually I’m trying to apply the ADC conversion formula on page 93-94 in PICDEM Lab Flowcode : http://ww1.microchip.com/downloads/en/D ... 41381B.pdf
Hi Jocelyn,
I don't believe you will be able to apply that foumula. Its not to do with Flowcode.
It's the way PIC maths work.
For example bytes are just whole numbers (no rounding up).
So 894/5=178
The problem will arise if result is less then 0 and not using float numbers or multiplying out first
E.g 1/1024*5000
= 1/1024 = 0
0*5000=0
Result = 0
If using a calculator results will be totally different
= 4.88 (2dp)
Your Flowchart using ADC ReadAsString will produce correct results on your LCD anyway,
So no need to apply that formula, since it's automatically done for you.
Jocelyn wrote: As sensor hardware is connected to RB4/AN10 pin of pic16f690 should then light the LEDs sequentially in an binary fashion representing the ADC result value.
Then, either using the ADC conversion formula to convert the binary value to decimal value or any other possible method to display decimal value on LCD.
The problem is If your using an input and an output on the same pin (i/p and RS of LCD), if not using a resistor in series with the i/p-o/p pin then if pot is used and middle connection is near the Ground to give 0V, then microcontroller will be supply too much current when pin is an o/p, hence will be damaged.

Also if your connecting LEDS to the LCD data line, then while LCD is being updated the LED will be going on and off with the LCD data.

Changing i/p to a diffident pin maybe the way to go.
Looking at your flowchart, your using An0 (pin 19 ) and not An10.
If you want to change to a different analog i/p then:
Right click on the pot on your Control panel and select connections.
From the drop down box select correct channel:
ADC connections.png
(32.4 KiB) Downloaded 2897 times
As for interfacing with thermistors:
The maximum i/p voltage to a microcontroller is the same as the supply voltage = 5V
Normally there is a resistor connected to 5V, a thermistor connected between other end resistor and 0V (GND of microcontroller)
The junction of resistor/thermistor connected to i/p of microcontroller.
Or the other way round i.e thermistor connected to +5V and resistor connected to the other end of thermistor and 0V
Take a look at page 102 of your attachment.

When you have decided what connections to use with your microcontroller, I can help you out with your code.

Martin
Martin

Jocelyn
Flowcode v5 User
Posts: 15
Joined: Thu Jan 31, 2013 11:38 am
Has thanked: 2 times
Contact:

Re: getting outputs from sensor into PIC16F690 LCD

Post by Jocelyn »

Hi Martin,
I would connect to AN10 then.
I've done the connection to thermistor, left the code part. Please kindly guide the code part...

Post Reply