Hi,
I am trying to get the ADC component working in Flowcode V3 while in simulation and it does not appear to be working (more like I am doing something wrong).
I have added the ADC(0) component block into a flowchart with a simple loop.
I have selected ReadAsInt and the return value is being poked into my return variable called ADC_RA0_Read (defined as INT).
The ADC(0) component block then flows into a decision block
If ADC_RA0_Read < 511
Yes --> code to turn on RB0 (LED)
No --> code to turn OFF RB0 (LED)
Loop back and read again, turn on/off LED
I have connected the "ADC(0)" component to the "ADC0" slider in component connections. Status is "Pin Analog in is connected OK"
Compiler set for 18F2620, 20Mhz, linker all default settings.
I start the simulator.....
When I move the slider UP all the way nothing appears to happen, my LED does not turn off. I would think the value would slowly go towards 1023 as I move the slider up and when ADC_RA0_Read is 511 or higher the LED would turn OFF.
What am I doing wrong?
Second question - 18F2620 has several ANx pins.
How do I tell Flowocde which real world pin ADC(0) should connect to? I think ADC(0) = AN0, ADC(1) = AN1 etc..... is this correct?
Thanks
Ron
ADC Component & Simulation
-
- Valued Contributor
- Posts: 548
- Joined: Tue Jun 26, 2007 11:23 am
- Has thanked: 6 times
- Been thanked: 44 times
Hello Ron,
The SampleADC function from the ADC component must be executed before each attempt to read a result.
The chip has a single ADC and an analogue multiplexer to connect the selected ANx input to it. Multiple ADC components can be loaded into a flowchart. Each one can be connected to a selected analogue input using its 'Component Connections' property.
Note:
If you load three ADC components into a flowchart they will be numbered ADC(0), ADC(1) and ADC(2). These are the component references and not the analogue channel numbers. Each instance of the component can be connected to any of the analogue inputs.
When the SampleADC function of an ADC component is run, the multiplexer selects the analogue input configured for that component and the ADC converts it. The result can then be read as either a byte or integer value.
The SampleADC function from the ADC component must be executed before each attempt to read a result.
The chip has a single ADC and an analogue multiplexer to connect the selected ANx input to it. Multiple ADC components can be loaded into a flowchart. Each one can be connected to a selected analogue input using its 'Component Connections' property.
Note:
If you load three ADC components into a flowchart they will be numbered ADC(0), ADC(1) and ADC(2). These are the component references and not the analogue channel numbers. Each instance of the component can be connected to any of the analogue inputs.
When the SampleADC function of an ADC component is run, the multiplexer selects the analogue input configured for that component and the ADC converts it. The result can then be read as either a byte or integer value.
Got it working
Sean,
Thanks for the info, go it working.
ReadAsInt
is actually more like
StoreSampleAsInt
Thanks
Ron
Thanks for the info, go it working.
ReadAsInt
is actually more like
StoreSampleAsInt
Thanks
Ron