ACS712 component doing wrong

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

Moderator: Benj

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: ACS712 component doing wrong

Post by JohnCrow »

Hi Monie

A few years ago I used one of these in FC4, so had to write the code myself.
Is this any help.

http://www.matrixtsl.com/mmforums/viewt ... it=+acs712
1 in 10 people understand binary, the other one doesn't !

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: ACS712 component doing wrong

Post by Monie Jacobsen »

Hi John

Yes I have seen your examble and in the moment I use it and it work fine
But now when Jordy have made a component for this ACSxx I any case it would be easyer to use for me. I would be Happy if anybody could fix it or make a new component. I am sadly not able to do it.
Best Regard
Monie

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: ACS712 component doing wrong

Post by Benj »

Hi Monie,

It seems Jordy's component is working fine, the problem your having is due to lack of ROM on the 877A device.
It seemed to work on Arduino. But on a pic16fxx I still get the compilemessage “ ROM available:8192 words, used:8248 words (100.6%), free:-56 words (0.-6%)” ??
So I wonder, how much rom does it use when I use a Arduino and am I also almost on the limit usage and why does it use so much space in a Pic??
Compiling for PIC using Flowcode 6. (Interestingly the program does seem to compile ok for Flowcode 7 using PIC.)
RAM available:368 bytes, used:252 bytes (68.5%), free:116 bytes (31.5%),
Heap size:116 bytes, Heap max single alloc:95 bytes
ROM available:8192 words, used:8692 words (106.1%), free:-500 words (-6.-1%)
Too much code to fit in ROM, overfilled by:500 locations.
Compiling for an Arduino Uno.
text data bss dec hex filename
7604 28 72 7704 1e18 C:\Users\BenR\Desktop\PIC16F876AampASC7.elf
The GCC compiler output is a little different but you can say that the ROM usage is the Text section and the RAM usage is the Data and BSS sections

So on AVR

ROM = 7604 bytes - close to the 8192 limit of the PIC device your using.
RAM = 100 bytes

What about using the PIC16F1937 or PIC16F1939 instead of the PIC16F877A? The 1937 has slightly more ROM available and the 1939 has more than double.

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: ACS712 component doing wrong

Post by Monie Jacobsen »

Hi Benj
Thanks for your reply Ben. Yes right I can use a bigger size , but if there is a bug in the component macro, I do not believe it is the right solution and just increase the size.

But Ben will try to look at the attached example. If you try to simulate it looks like that the 2 analog inputs have influence on each other, and it act the same way in real world.

Attached error eksemple:
ArduinoAampI2C-Channel.fcfx
(8.07 KiB) Downloaded 478 times
Best Regard
Monie

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: ACS712 component doing wrong

Post by Benj »

Hello Monie,

Aha it seems the current ACS712 component is not switching analogue channel to reflect your property change.

To check this click View -> Component Debugger.

Click to check the "Expose full component tree" item in the Component Debugger window.

On the properties window select the drop down menu at the top of the window.

Select the Slider Plastic component just underneath the ACS7xx component.

The Channel property is still set to 0, changing this property should correctly allow you to configure the Analogue pin connection of the component.

You can double check that this has worked by looking at the properties of the ADC base or CAL ADC components underneath the Slider Plastic component.

Alternatively you can check by looking at the generated C code.

There should be two sections like the code below, one for each ADC based component you have on the panel.

Code: Select all

#define ADC_2_MX_ADC_ACTIME 40
#define MX_ADC_REF 
#define ADC_2_MX_ADC_VREFVOL 500
#define MX_ADC_CHANNEL_0 
#define MX_ADC_TYPE_2 
#define ADC_2_MX_ADC_VREFOP 0
#define ADC_2_MX_ADC_CONVSP 3
#define MX_ADC_BITS_10 
#define ADC_2_MX_ADC_CHANNEL 0

Code: Select all

#define ADC_1_MX_ADC_ACTIME 40
#define MX_ADC_REF 
#define ADC_1_MX_ADC_VREFVOL 500
#define MX_ADC_CHANNEL_3 
#define MX_ADC_TYPE_2 
#define ADC_1_MX_ADC_VREFOP 0
#define ADC_1_MX_ADC_CONVSP 3
#define MX_ADC_BITS_10 
#define ADC_1_MX_ADC_CHANNEL 3

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: ACS712 component doing wrong

Post by Monie Jacobsen »

Hello Benj

Thank´s.

I try your suggestion, but it doest work I still get the same error -2 Used to much rom.
Is it difficult to create a new component?
Sadly I am not able to do it.

GO'Weekend
Best Regard
Monie

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: ACS712 component doing wrong

Post by Benj »

Hi Monie,

It's a bit of work to create a component and at the moment we have a very busy schedule. It's not difficult as such but there is a lot to get right.

I can probably eventually build a new component to get rid of the ADC channel bug we have discovered. However this will probably not decrease the ROM usage so you will still get the "Out of ROM" type compiler error messages.

For now it should be possible to work around the ADC channel bug using the fix I posted and using a Microcontroller with more available ROM.

tadz
Posts: 1
Joined: Fri Dec 27, 2019 1:40 pm
Has thanked: 2 times
Contact:

Re: ACS712 component doing wrong

Post by tadz »

hi sir john

i've seen your project very helpful, I am working on a project that has to work for AC Current reading. Can someone please help me modify a code for AC Current Reading using this ACS 712 current sensor. Thank you everyone.

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: ACS712 component doing wrong

Post by Steve001 »

Hi Tadz

When using AC these type of sensors will output a AC Waveform
one option is by using a "precision rectifier" and a small capacitor to convert this to DC then the standard ADC component can read the value

https://en.wikipedia.org/wiki/Precision_rectifier

Hope this helps

Steve
Success always occurs in private and failure in full view.

Post Reply