Issues with reading an analogue voltage signal

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

Moderator: Benj

Post Reply
Aidan_OSullivan
Posts: 13
Joined: Wed Jun 05, 2019 9:57 am
Has thanked: 7 times
Been thanked: 2 times
Contact:

Issues with reading an analogue voltage signal

Post by Aidan_OSullivan »

We have been attempting to a read an anlogue input from a power supply to our BL0011 board. We are using the analogue pin E0. When we try to display this on our LCD screen it is coming up as either active low or active high depending on the input voltage. We would like to display the voltage as an analogue reading.
We were trying to figure out how to configure the internal ADC but were unable to do so from the program. As an alternative we tried using C code to store this voltage value using analogRead, as seen below:
FCV_Voltage = analogRead(E,0);
We were given the following errors- 9643: FCV_Voltage = analogRead(E,0);
^ (192) undefined identifier "FCV_Voltage"
^ (361) function declared implicit int (warning)
^ (192) undefined identifier "E"
Should this C code method work or is there another alternative using the internal ADC? Any assistance with this would be greatly appreciated!

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: Issues with reading an analogue voltage signal

Post by medelec35 »

Hi Aidan,
It would help if you can post the flowchart that's got the issues you describe.
Martin

Aidan_OSullivan
Posts: 13
Joined: Wed Jun 05, 2019 9:57 am
Has thanked: 7 times
Been thanked: 2 times
Contact:

Re: Issues with reading an analogue voltage signal

Post by Aidan_OSullivan »

Mi Martin, I have attached the file using C code to read the analogue signal.
If that method isn't possible I am wondering if there is any way to use a component macro such as the 'IO_ReadAnalogasByte' that is available to read the analogue signal from either the LDR or POT that could read the analogue signal from the external power supply?
Attachments
AnalogueMeasurement.fcfx
(15.75 KiB) Downloaded 190 times

User avatar
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: Issues with reading an analogue voltage signal

Post by Benj »

Hello,

This should help. I've added an ADC input from the Inputs component category and connected it to pin E2 via the component properties.
AnalogueMeasurement.fcfx
(15.83 KiB) Downloaded 206 times

Aidan_OSullivan
Posts: 13
Joined: Wed Jun 05, 2019 9:57 am
Has thanked: 7 times
Been thanked: 2 times
Contact:

Re: Issues with reading an analogue voltage signal

Post by Aidan_OSullivan »

We have now successfully managed to read an analogue signal from the power supply. We are then routing this from the ADC to the DAC in our SPI master board (EB013). The output from the DAC is coming out as approximately half of our input voltage. The output of the DAC is an open circuit so no divider network is being created. Is there any way of creating close to a 1:1 input to output in the DAC?

User avatar
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: Issues with reading an analogue voltage signal

Post by Benj »

Hello,

The difference could maybe be down to a different bit depth between the adc input and the DAC output.

What about doubling the digitised adc reading?

output = adc * 2

or more efficient but does the same thing.

output = adc << 1

Post Reply