looking for advice

For general Flowcode discussion that does not belong in the other sections.
max.tisc
Posts: 55
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 5 times

looking for advice

Post by max.tisc »

hi all,
I ask you my doubt, I state that I have created a flow meter that seems to work quite well, I'm on the part concerning the totalizer, the problem is that the totalizer data must be saved at least every second, so that in case of power failure on restart it starts from the last saved value and not from 0, I thought about saving on EEPROM but then I thought that they have limited read and write cycles and I don't want to break it, is this correct? If so, how could this problem be solved? I read that F-RAM (exsample type FM25V02 Cypress) supports trillion cycles, does FC9 support such memories?
thank you

RGV250
Posts: 273
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 24 times
Been thanked: 30 times

Re: looking for advice

Post by RGV250 »

Hi,
Flowcode is just the compiler so it will support whatever the device hardware is capable of.

Bob

medelec35
Matrix Staff
Posts: 1457
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 513 times
Been thanked: 473 times

Re: looking for advice

Post by medelec35 »

Hello.
What about an alternative method?
What I have done in the past is supply microcontroller VDD via a diode from +5v.
I would recommend a Schottky diode as it has a lower forward voltage drop.
The Anode is conneted to +5V power supply and cathode is connected to VDD of the microcontroller.
Connect a 470uF capacitor across microcontroller VDD and GND
Connect an interrupt (I used INT0 on falling edge, but you can use IOC as well) To +5V supply.
When the power goes off, the interrupt (INT0, IOC on falling only), etc is triggered, which in turn calls the macro that saves all variables to EEPROM
The 470uF capacitor should keep VDD high for long enough.
If a fair few variables then you may have to increase the Cap value, but at least you have a starting point.

You need to take into account that the interrupt will more than likely be triggered more than once.
So you will need to have a way of dealing with any subsequent triggering within a short space of time e.g. using flag variables.
E.g. within the interrupt have a decision branch
If InterruptEnable = 1: then InterruptEnable = 0 : SaveEEPROMdata = 1.
The InterruptEnable variable is initialized with 1 and SaveEEPROMdata variable is initialised with 0.
Within main you could have If SaveEEPROMdata = 1: Call EEPROM save user macro: InterruptEnable = 1:
Martin

max.tisc
Posts: 55
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 5 times

Re: looking for advice

Post by max.tisc »

ok thanks for all the advice

steve001
Valued Contributor
Posts: 185
Joined: Wed Jan 13, 2021 7:15 pm
Has thanked: 81 times
Been thanked: 30 times

Re: looking for advice

Post by steve001 »

Hello Just read this post.

Here is another alternative if you wish

Several years ago i made a Data Logger with a Vdrive and wanted the .txt file to be closed properly and vdrive exited correctly on a power failure.
I did some tests with some super capacitors - this is on the old forums

https://www.matrixtsl.com/mmforums/view ... =7&t=17713

If you don't fancy soldering the DFN ic's as these are tiny !, MIKROE do a supercapacitor charger as a board is a few different versions now

Have a look at the UPS CLICK Boards - these can be found in the battery charger section

https://www.mikroe.com/ups-click
https://www.mikroe.com/ups-3-click

Steve

alanwms
Posts: 117
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 24 times
Been thanked: 7 times

Re: looking for advice

Post by alanwms »

My method of saving data at power down was to feed the supply DC voltage into an analog input and constantly poll the analog watching for a voltage below a limit value.
Your smoothing capacitor will provide enough energy to allow your macro to run and save variables in eprom. I have posted the schematic showing the analog input highlighted in yellow. It routs through a resistor network which is a potential divider simply providing around 4 volts from the raw side of the DC before regulation.
This allows the 5v to remain while the power is depleting since the regulator remains active until around 7v input.
I use the resistor network because assembly is quicker than picking out a bunch of individual resistors. System works fine.
Attachments
epromsave.jpg
epromsave.jpg (125.58 KiB) Viewed 1694 times

steve001
Valued Contributor
Posts: 185
Joined: Wed Jan 13, 2021 7:15 pm
Has thanked: 81 times
Been thanked: 30 times

Re: looking for advice

Post by steve001 »

Morning,

NIce,

A couple of things to be aware of, that i found whilst experimenting before i went the power path route
If the input voltage to the regulator drops rapidly then the micro might not save your data / detect that the voltage has dropped. This all depends on the load of the 5 Volts

When writing to your eprom try and use a different location to spread the wear

Steve

alanwms
Posts: 117
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 24 times
Been thanked: 7 times

Re: looking for advice

Post by alanwms »

The input can't drop fast due to the input capacitance which has enough stored energy to run the regulator which keeps system 5volts until the input capacitor in depleted to around 7 volts.
As you can see, my monitor voltage is derived from the 17V power. So the scenario you suggest is not possible. The input voltage to the regulator can't go away fast even if you remove AC power - The reservoir capacitor is just that - a reservoir of power.

Lambra
Posts: 6
Joined: Thu Nov 24, 2022 11:55 pm

Re: looking for advice - help please..

Post by Lambra »

Hello - not sure where to post this request.?? In an ULTRASONIC transducer - it has to operate at 40 000 Hz.. to be able to radiate correctly. this means a pulse width of 25 usec.!! the +ve going pulse lasting for 12.5 usec. - the -ve going pulse lasting for 12.5 usec.. I have generated a transmitter pulse train... of 5 pulses.. then a break of 100 msec .. then another 5 pulses .. a break of 100 msec.. etc etc for a total GROUP of pulses of say 5..
That seems to be the easy part..!!
The receiver part.. is not so easy - AS I RAPIDLY FOUND OUT.!!!! - to decode the pulses is proving to be a problem... can anyone help me please.. The circuit is as follows.. there is an amplifer like MCP602 through to PIN 6 - RB0 of a PIC 16LF88 at 8000000 Hz..!! RB0 is the INT pin of the PIC.

I was believing that I could setup an interrupt - so that a pulse on the INT pin.. would then start a TIMER .. quickly I relized that possibly FLOWCODE9 could not handle this in icons.. BUT only in C-coding.!! the idea is to whack through the 5 incoming pulses.. in a certain time (TIMER)..only. if more than 5 pulses - arrived - external noise .. possibly.. the TIMER would have timed out.. and 5 pulses would be decoded.?? hmmm..then a break of 100 msec.. then another 5 pulses again.. WOW.. I am completely lost here..?? pleasee..?? - slowly - please.?? can anyone believe that they couold help me.. here.. the PCB are made up.. they were used before in another system.. that worked differently.. the highest frequency is 8000000 Hz.
I will be very pleased..? if someone could help me..?? and then I COULD LEARN SOMETHING NEW... which will make me very excited.. I have to learn something new.. everyday.!!
regards - Lambra...

mnfisher
Valued Contributor
Posts: 969
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 515 times

Re: looking for advice

Post by mnfisher »

There are several examples of doing this on the board - though for different message protocols.

viewtopic.php?t=1120

Which decodes ir signals.

See if you can modify the code from this thread - if you are having bother then please post your code and someone may be able to help..

Martin

Post Reply