Current LCD 4X20 fluctuation

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

Moderator: Benj

Post Reply
linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Current LCD 4X20 fluctuation

Post by linktech »

Good Day

I was recently writing some code to read the current value in the LCD Display but unfortunately, I was getting a high fluctuation value in the display after I upload the hex file to my hardware. When I was doing Flowcode 9 simulation the reading was perfect in the software tool simulation.

My digital PSU shows perfect current value 4.0Amps,after I load the hex file into my hardware there a high fluctuation happens.

I have attached the fluctuation pictures in my LCD display and my digital power supply current reading.

I need someone's help.

thank you
Attachments
1675747006603.jpg
1675747006603.jpg (84.58 KiB) Viewed 58689 times
1675747006593.jpg
1675747006593.jpg (85.03 KiB) Viewed 58689 times
1675747006587.jpg
1675747006587.jpg (72.18 KiB) Viewed 58689 times

linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Current LCD 4X20 fluctuation

Post by linktech »

Good Day

I was recently writing some code to read the current value in the LCD Display but unfortunately, I was getting a high fluctuation value in the display after I upload the hex file to my hardware. When I was doing Flowcode 9 simulation the reading was perfect in the software tool simulation.

My digital PSU shows perfect current value 4.0Amps,after I load the hex file into my hardware there a high fluctuation happens.

the value was jump from 3.75A TO 5.39A this always happens , i also have set the delay from 1sec to 3sec is same and i have chage the oscillation speed from 4.0Mhz to 20Mhz is also same thing was happnes.

(THIS WAS MY SECOND POST)

I have attached the fluctuation pictures in my LCD display and my digital power supply current reading.

I need someone's help.

thank you
Attachments
Current Reading.fcfx
(11.74 KiB) Downloaded 220 times
1675747006607.jpg
1675747006607.jpg (82.12 KiB) Viewed 58708 times

User avatar
Bachman
Posts: 116
Joined: Sun Sep 07, 2014 11:37 am
Location: Hungary
Has thanked: 9 times
Been thanked: 53 times
Contact:

Re: Current LCD 4X20 fluctuation

Post by Bachman »

Show us the PCB and schematic. I think, you got high noise and/or something not connected properly. Can you check the ADC input pin with Oscilloscope?

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Current LCD 4X20 fluctuation

Post by chipfryer27 »

Hi

I see you are attempting to use the internal oscillator of the 887 but have forgotten to include the necessary C-Code.

The 887 can run at 8MHz (max) using the internal oscillator (but can be divided down). See p63 of datasheet.

You need to add in the C-Code block at the very beginning of your chart then include the actual code to set the internal oscillator. For 8MHz operation it would be osccon=0x70;

The Clock setting you see under Build > Project Options needs to be changed to suit too. This setting is for FC to generate accurate timing / delay and must match actual clock speed. So if using an 8MHz internal clock this should be set to 8000000

I've attached the changes above.
Current Reading_Mod.fcfx
(7.32 KiB) Downloaded 212 times
Does this help?

Regards

EDIT
Ooops..... I forgot to change Clock Setting from 20 to 8MHz in the attached file. Done now.

linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Re: Current LCD 4X20 fluctuation

Post by linktech »

hi, good day to you

i completed your edit code and generate a hex file, but was error happened i can't generate a hex file , the error below

Microchip MPLAB XC8 C Compiler V2.10
Build date: Jul 30 2019
Part Support Version: 2.10
Copyright (C) 2019 Microchip Technology Inc.
Current Reading_Mod.c: main()
1208: osccon=0x70;
^ (192) undefined identifier "osccon"
(908) exit status = 1
(908) exit status = 1

The error returned from [xc8.exe]



thanks you

linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Re: Current LCD 4X20 fluctuation

Post by linktech »

Bachman wrote:
Tue Feb 07, 2023 11:41 am
Show us the PCB and schematic. I think, you got high noise and/or something not connected properly. Can you check the ADC input pin with Oscilloscope?
hi, good day

I have attachment the schematic for input/output/analog signal to MCU pin.

please find pdf file attachment.

thank you
Attachments
SCHEMATIC ANALOG.pdf
(88.76 KiB) Downloaded 221 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Current LCD 4X20 fluctuation

Post by chipfryer27 »

Hi

It compiled OK for me. What version of FC did you use when compiling? As you posted in the v6 forum I used code compatible with that, but if using v7 onwards (or perhaps another compiler) then you will need to capitalise the register

OSCCON=0x70;

Regards

linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Re: Current LCD 4X20 fluctuation

Post by linktech »

Good Day

I used 2 types of Flowcode and tried
1. FC7 (i was purchased in the year 2016 with pic16 license spec)
2. FC9 (recently just only I was purchased from the matrix with full license spec)

Both I do compile errors that appear with the same error code after you edit in my FC file OSCCON=0x70;

I really need your help to solve this issue, we are in developing a project we hunting for the death line, suddenly is happen this problem

Thank You

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Current LCD 4X20 fluctuation

Post by chipfryer27 »

Hi

If using v9 you should post in the v9 forum.

The attached has an IntOsc Helper which in v9 can be found at Component Libraries > Runtime > Matrix Tools and it will help set your oscillator.

This compiles OK for me in v9
Current Reading_Mod_v9.fcfx
(12.63 KiB) Downloaded 223 times
Have you tried reinstalling toolchains?

Regards

linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Re: Current LCD 4X20 fluctuation

Post by linktech »

Hi,

after you did IntOscHelper1 I can generate a hex file in FC9, the reading is the same happens the fluctuation.

I also tried to add some filtration capacitors in VDD and also in the input voltage connections, but no changes.

how to solve this problem?

Thank You

linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Re: Current LCD 4X20 fluctuation

Post by linktech »

I already remove and reinstall the toolchains.
is same happens

thanks

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Current LCD 4X20 fluctuation

Post by chipfryer27 »

Hi

Glad to hear you can now compile. My suggestions were to help you configure the microcontroller correctly.

Now that is done you can look at the hardware, especially as those current readings on the PSU seem very large indeed.

The schematic you provided as per Bachman's request doesn't help too much. What is your input voltage and what is the value of your load resistor that I assume connects across J24? I presume your circuit is more than just shown.

Regards

linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Re: Current LCD 4X20 fluctuation

Post by linktech »

Hi,

What is your input voltage and what is the value of your load resistor that I assume connects across J24?
INPUT VOLTAGE: 0 ~ 12VDC FROM ADJUSTABLE DIGITAL POWER SUPPLY.
J24 : I CONNECT 1R/50W POWER RESISTOR

I have connected with battery 12v and test, the fluctuation is the same
I reduce the resistor value to 20R/10W on the J3 load side.

another method I inject voltage 1.2vdc directly to MCU RA0/AN0 and test for 5 minutes is show fluctuation, to ensure my hardware is ok.

I really do know how to solve this kind of problem

Thank You

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Current LCD 4X20 fluctuation

Post by chipfryer27 »

Hi

Sorry to be brief as I need to head out just now.

What voltage does your MCU operate at? I assume 5v but is it derived from the same PSU as powering the rest of your circuit?

Testing the MCU by itself is a good start. With no averaging / filtering I would expect fluctuations with a 10-bit ADC (approx 4.8mV resolution @5v).

What values do you get when only powering the circuit shown? Your PSU picture shows 4A but only 0.8v which suggests a resistance of 0.8/4 = 0.2 Ohms across the PSU (which is as good as a short circuit). Have you checked your circuit for shorts/damaged components?

Regards

linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Re: Current LCD 4X20 fluctuation

Post by linktech »

Hi,

What voltage does your MCU operate at? I assume 5v but is it derived from the same PSU as powering the rest of your circuit?

Not the same PSU to MCU, I was using separate a battery input voltage 12vdc and have regulator ic 5V output and connected to MCU VCC/VDD PIN.

when I measure GND to VDD MCU POWER PIN, I GET VOLTAGE 4.98vdc which is the correct voltage point, and I also do some data logging with my BK Bench multimeter in the GND/VDD pin there is no voltage drop or fluctuation.

What values do you get when only powering the circuit shown? (when I was injecting with direct voltage to RA0/AN0 1.02V I GET READING IN THE DISPLAY ) the measuring current delay timer I set to 1sec and clear display.

FIRST VALUE: 2.75A
SECOND VALUE: 5.50A
THIRD VALUE: 5.27A
FOURTH VALUE: 5.73A

This value I was getting fluctuation some time can jump to 6.01A

Your PSU picture shows 4A but only 0.8v which suggests a resistance of 0.8/4 = 0.2 Ohms (YES CORRECT)

Have you checked your circuit for shorts/damaged components? ( I was total check my development Board there is no component damage or open circuits/short circuits in the board)

I also replace PIC16F877A and test, it shows the same results fluctuation.

Best Regards

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Current LCD 4X20 fluctuation

Post by chipfryer27 »

Hi

I am a little confused and not entirely sure I understand what you are trying to achieve.

Are you saying that your display is showing fluctuating values between 5.27 and 5.73 or is that what is happening on your PSU?

With your MCU disconnected, what voltage is your PSU set for and what does it show when connected to the schematic you posted earlier and what value is across J24?

With the settings you have, the resolution is 0.0048V but with your scaling that equates to 0.234 so it only takes a fluctuation of mV's at the input to show as a significant change on the display.

I'd suggest to familiarise yourself with the ADC, averaging and filtering, and a good guide with examples is here

https://www.flowcode.co.uk/wiki/index.p ... DC_dial_()

Hope this helps.

Regards

linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Re: Current LCD 4X20 fluctuation

Post by linktech »

Hi

I have made you very clear since my first post in this forum.

YOUR QUESTIONS: Are you saying that your display is showing fluctuating values between 5.27 and 5.73 or is that what is happening on your PSU?
MY FRIEND IS NOT MY PSU FLUCTUATION, THE LCD DISPLAY FLUCTUATION BELOW THE VALUE
FIRST VALUE: 2.75A
SECOND VALUE: 5.50A
THIRD VALUE: 5.27A
FOURTH VALUE: 5.73A

PLEASE READ MY POST AGAIN

With your MCU disconnected, what voltage is your PSU set for and what does it show when connected to the schematic you posted earlier and what value is across J24? I TOLD YOU EARLIER THAT 12VDC TO THE J24.

With the settings you have, the resolution is 0.0048V but with your scaling that equates to 0.234. WHERE DO YOU GET 0.234? I HAVE NOT MENTIONED THESE NUMBERS IN THIS FORUM

I SAID I WAS INJECTING DIRECTLY TO MCU RA0/AN0 PIN 1.02VDC THIS VOLTAGE IS CONSTANT VOLTAGE FROM MY DIGITAL PSU IS NO FLUCTUATIONS.


EXAMPLE:
ADC Program Flowcode setting point
ADC0 /RA0/AN0
VRef voltage 500
Vref Option VDD

IF I NJECT DIRECTLY TO MCU PIN RA0/AN0

PSU Input Voltage LCD DISPLAY RESULTS
1V = 1AMPS
2V = 2AMPS
5V = 4.999 to 5.0A

this is the reading suppose I must get in my LCD, not more than this value suppose +/- Fluctuation 0.01 is acceptable.

But in my case more than a 50% difference I read on my LCD display, is unacceptable.



(Input Voltage 1.02V) (My display results)
FIRST VALUE: 2.75A 5.73A - 2.75A = 2.98A
SECOND VALUE: 5.50A 5.50A - 2.75 = 2.75A
THIRD VALUE: 5.27A 5.27A - 2.75A = 2.52A
FOURTH VALUE: 5.73A 5.73 A - 2.75A = 2.98A

===================================================

TOTALLY UNACCEPTABLE DISPLAY READING.

THE ONLY WAY I GOING TO WRITE THE EXAMPLE CODE IN MPLAB IS C.CODE AND TEST OR ARDUINO UNO R3.

THANK YOU VERY MUCH FOR YOUR SUPPORT.

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Current LCD 4X20 fluctuation

Post by chipfryer27 »

Hi

I said in my previous post that I was unclear, therefore I requested further information. If, as you suggest, you had already provided all details then I wouldn't be asking for clarification to try and assist you further.

As an example, you state you are running at 12v, but the picture supplied shows your PSU with 0.8v @ 4A (which looks suspiciously like it cannot supply the necessary current the circuit dictates). If things are as you suggest, then at 12v with your 1Ohm resistor in J24 plus your paralleled 0.1 Ohms it would be around 12A. Basic Ohms Law provides that.

A further reason for requesting clarification is that you seem to change parameters. Your chart shows a Vref of 24,000 but your post above states 500 yet you ask where I am getting my values from.

You have not shared details of any smoothing or decoupling on your MCU. Bachman gave an excellent suggestion to "scope" your input pin, which would show exactly what is happening there and may surprise you.

I provided a link that will explain using FC with ADC, averaging and filtering which I suggest you read.

Good luck with your project.

Regards

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Current LCD 4X20 fluctuation

Post by Steve »

@Bachman and @chipfryer27 - Thanks for your attempts to solve this fellow user's problem. This forum greatly benefits from users like you sharing your wisdom and time trying to help others - it is much appreciated.

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: Current LCD 4X20 fluctuation

Post by Benj »

Hello,

I've had an email regarding this problem and so I thought I would copy the email reply here too for completeness.

Looking at the project the first thing that jumps out is the pot_ptr_black Acquisition cycles is set to 1, this is the time to allow the ADC capacitor to charge before doing a conversion. A value of 1 is highly likely to be causing very inconsistent readings. I would try increasing this to something more like 40. If speed of sampling were a problem then once you have this working well you can try reducing this number.

Next there may be significant noise on the ADC input, maybe an external RC low pass filter before the ADC pin would help to try an minimise any noise.
http://sim.okawa-denshi.jp/en/CRlowkeisan.htm

Some noise can be overcome in software by taking a number of samples and averaging the reading. This could be done by using the GetAverageInt function and then multiplying up the result to provide the floating point voltage they are currently displaying.

Adding automatic averaging to the GetVoltage and GetString functions is something we can look at doing for v10 as I can see this would be useful.

linktech
Posts: 27
Joined: Wed Aug 17, 2016 5:03 pm
Been thanked: 1 time
Contact:

Re: Current LCD 4X20 fluctuation

Post by linktech »

good day to all

I don't have time to spend on this forum ,I don't see the problem solve.

thank you very much

User avatar
AbhijitR
Posts: 298
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 279 times
Been thanked: 78 times
Contact:

Re: Current LCD 4X20 fluctuation

Post by AbhijitR »

Hello! Linktech

In my humble opinion you should be patient and endeavoring while doing any project or work.

Forum is a place where everyone try to help as much as possible as per there convenient time and availability.

If you are willing to get your project solved quickly try to avail services provided by freelancers.

All my best wishes for your work.

Regards

Post Reply