Hi
I am using an adc to monitor a variable voltage from 0V to 50V. I am using a potential divider, so as a 50V input to the divider, would mean a 5V input on the adc and 1024 as integer variable. Up to here its ok. My problem is when I am going to display that integer on the LCD. I am dividing the integer in 2 parts. When the voltage is greater than 10V it displays 10.00 and so on . But when the number is less than 10V e.g 7.5xxV it displays 75.xxV.
I need to shift that value one to the right so as to display 07.5xV. But how can I do this, as the only problem is for voltages under the 10V??!!
Thanks
kirstom14
adc problem + display
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: adc problem + display
Hello Kirstom
You could divide the result by 10 if it is smaller then ten.
Alternatively if you wish to keep the decmial point operation you could use the 32-bit floating point library.
There is a walkthrough on how to use this available from the Flowcode V3 section of our Support Centre.
You could divide the result by 10 if it is smaller then ten.
Alternatively if you wish to keep the decmial point operation you could use the 32-bit floating point library.
There is a walkthrough on how to use this available from the Flowcode V3 section of our Support Centre.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 548
- Joined: Tue Jun 26, 2007 11:23 am
- Has thanked: 6 times
- Been thanked: 44 times
Re: adc problem + display
Hello,
The problem seems to be that the leading-zero surpression of the PrintNumber function is changing the format of your display when the integer part of the result changes from 2 to 1 characters.
One solution could be to test for this case before the result is printed, and if the integer part is only one character, use the PrintASCII function to print a leading '0' character.
The problem seems to be that the leading-zero surpression of the PrintNumber function is changing the format of your display when the integer part of the result changes from 2 to 1 characters.
One solution could be to test for this case before the result is printed, and if the integer part is only one character, use the PrintASCII function to print a leading '0' character.
Re: adc problem + display
Hi
I divided the integer by 10 and then multipling it by 5, as the maximum input voltage is 50V. Then I used the string manipulation to divide the number in two parts and then displaying them. This worked fine on the flowcode simulation. But when simulating the whole cct on Proteus Isis, when I give an input voltage of 0V, the LCD displays 5V,, I don't know how a 0*5=5????. Can the error is caused by the Isis and in real time it would work well???
Thanks
I divided the integer by 10 and then multipling it by 5, as the maximum input voltage is 50V. Then I used the string manipulation to divide the number in two parts and then displaying them. This worked fine on the flowcode simulation. But when simulating the whole cct on Proteus Isis, when I give an input voltage of 0V, the LCD displays 5V,, I don't know how a 0*5=5????. Can the error is caused by the Isis and in real time it would work well???
Thanks
tomcat14
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: adc problem + display
Hello Tomcat
Isis is normally pretty stable. I used it to simulate a 2 axis analogue joystick and it all worked fine. Could it be that the voltage in Isis is the opposite of what you are expecting. The Flowcode ADC simulation is tried and tested so at least this can be counted on.
Isis is normally pretty stable. I used it to simulate a 2 axis analogue joystick and it all worked fine. Could it be that the voltage in Isis is the opposite of what you are expecting. The Flowcode ADC simulation is tried and tested so at least this can be counted on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel