Dc voltmeter 0-55v

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

Moderator: Benj

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

It does not flicker now but the half lit LEDs are so much now almost identical to the lit ones.I think we will have to try this out on my new hardware with a 32MHz osc I think it can be really cool to see the 7seg dim messages in and out softly as they fed away more so those that are not in critical positions of the code can be those ones like may be at the start of the prog or even out of the critical loops of the code.

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: Dc voltmeter 0-55v

Post by medelec35 »

I have worked out that due to rapidly turning port pins on and off that the higher the interrupt frequency the more the LED' are on that should not be.
Even though dim in comparison to ones that are on has an increased effect in which you have reported.
Therefore I have a much better plan B
Have the emitters of transistors that control all the digits, connect to a collector of just one NPN transistor.
So this one transistor will sink the current from all the transistors connected to each digit.
This new transistor can be PWM controlled from the built in PWM module.
Using this method, the interrupt controlling digits can as low as 200Hz, therefore eliminating the unwanted dimly lit segments.
The last flowchart sent, can be ignored.
So with your next hardware, you need to check what pins you can use for PWM so you can use that to contol brightness.
I have just tried that method on hardware and works perfect!
Although I have a common anode Eblock, so used a PNP transistor.
No LED segment is on when should not be, even with PWM making all the display very dim e.g 3% brightness.
Attached are images from either end of brightness range.
Display is directly showing brightness percentage i.e 3.44% & 99.0%:
Dimming Display.png
(215.78 KiB) Downloaded 756 times
You can clearly see the 3.44 with no unwanted segments dimly lit.
Only slight noticeable issue if too dim, first digit is always slightly brighter then the rest.
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

It's like you are saying i connect all the common pins of the 3 digits go through one collector of one transistor right? If yes you realize how that will be hard for me to bring back my 7seg to normal individual auto control in the critical loops since all the digits go through one collector permanently unless we bring a 4th transistor in the game in that @ the time of doing this i cut off siginal to the other two transistors in code then the 4th transistor connects the commons of these two to the PWM one and when am done with the dimming the 4th transistor is kicked out and boom bring back my two siginals in code.am i getting this right??!!!!

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: Dc voltmeter 0-55v

Post by medelec35 »

Derrihj wrote:It's like you are saying i connect all the common pins of the 3 digits go through one collector of one transistor right?
It needs to go though an additional transistor.
So if you have 3 transistors controlling 3 digits, you will need to add a 4th transistor.
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Ok will first try out the manual one and see how it handles the dimming then if am impressed will have to fix it in my hardware tho looks like i have no more free pins on there for the 4th transistor.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Can the calculation icon be changed to make calculations in DEG or RAD or GRAD when am dealing with the likes of sin() , log() or that doesn't matter for the calculation icon in flowcode. and somewhere somehow when i say: a=(2x0.4) then i say: sin(a) i get 0.000 which is dead wrong i should be getting a. 0.71735 but when i put the number it's self instead of (a) i get the correct answer how is this

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Ok i realized a was supposed to be a floating point number a friend of mine had brought his code for trouble shooting i found out he had used a byte instead of float for values of (a)

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Hi Martin hope you are having a good day please help me on this one too; How do i get exactly my FireDelay on the display on the press of a button.Wanted to map it in the delay icon but seems like it does not take in float numbers tried the count trick but it is giving me a slightly different number in ms yet i need it to be exactly as Default.Please help edit for me am doing this coz in the code i will need to varry values of FireDelay.
Attachments
Phase Angle Charging.fcfx
(13.02 KiB) Downloaded 191 times

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

This is the new trick i have used but still haven't got the right timing, tried to bring in Timer0 what i want is, i will be adding 0.03315ms or subtracting 0.03315ms from Variable named FireDelay in code in order to add or subtract 1 volt from Vrms as seen from this: Vrms = 220(1/pi(pi-a+sin(2a)/2))power(1/2) Where (a) is got from my FireDelay Variable.Check the flow-chat below is close to what i want but I get bad timing.
Attachments
Phase Angle2.fcfx
(15.72 KiB) Downloaded 182 times

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

I created a prog that calculate the values of Vrms as you Varry FireDelay if you want i can post it so that you see what happens when ever you add or subtract a 0.03315ms from FireDelay.

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: Dc voltmeter 0-55v

Post by medelec35 »

Hi Derrihj,
Interrupt is completely wrong.
You have INT0 calling EXTint ISR macro.
Witin EXTint Macro you have Enable TMR0 & Disable TMR0
The enable TMR0 within EXTint Macro is calling a different ISR macro.
You should avoid enabling interrups , delays, components with delays etc within interrupts.
Surprised its working at all
I will see if I can think of a better way to do this?
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Thanks Martin i will be waiting as i really need this coz i will always be adding or subtracting 0.03315ms from FireDelay as i want the prog to operate in response to current and voltage.

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: Dc voltmeter 0-55v

Post by medelec35 »

With

Code: Select all

FireDelay = 7.2545254
is the 7.2545254 milliseconds?
So what you need to do is when an external pin goes low, delay for either 7.25449225ms or 7.25455855ms?
If so that's a fair bit of precision
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Yes when ever at the falling edge of Int0 siginal is delayed by FireDelay variable and if I want to add a 1 volt change on Vrms on the next falling edge, i add or subtract 0.03315ms from my variable.Am still working out the formula above for values of (a) for a more close precise value to give me exactly 1 volt inclease

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

As you think of the way to clap it off let me calculate the exact values i will be using that is the initial value of FireDelay and the then the exact 1 volt value to be added or subtracted then i will update my prog that i created send it to you and check what happens then you do your thing i trust you and i know you will come up with a way to deal with this.

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: Dc voltmeter 0-55v

Post by medelec35 »

What's the lowest resolution in time you can get away with?
An interrupt working at 1uS resolution with 8bit devices is practically.
So need to know by how much time can deviate by?
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Sorry for the delay but Ac mains went off in our area at night due to some problem it has just been restored but below is the flowchat, as you add or subtract 0.030303ms from firedelay variable, should give you a 1 volt Vrms out decrease or increase respectively.So my initial value for Fire delay variable is: 5.4788ms and a close 1 volt value of 0.030303ms.So this 0.030303 value is not exactly giving me a 1 volt so if you deviate away from it the more you get away from the 1 volt will try to look for a close value but for now we can work with that.So in the flow-chat below you just add or sub 0.030303ms from the initial firedelay in the calculation box place play and see the new Vrms on the LCD so you can do your thing and if you get the new 1 volt value considering all the interrupt resolution come to this flowchat add what you got in ms to the initial firedelay variable and see the resultant Vrms .should show you by how much it deviates away from the 1 volt. Or if you wanted to add a 1 volt on the default 140v to get 141 but you get 141.54543v then it should show you by how much you deviated
Attachments
Phase Angle Delay and Vrms Out.fcfx
(13.53 KiB) Downloaded 135 times

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

I would like to get a 1 volt but i think a half a volt deviation or not more than one deviation can be ok i wouldn't like to be adding or subtracting a 2 or more volts on Vrms.Do you think if we canvert the ms to uS can make life easier? Just asking

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: Dc voltmeter 0-55v

Post by medelec35 »

Different flowcharts are at different clock speeds.
Is it 32MHz?
The higher the better.
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Yes it should be 32MHz i must have forgot to change sorry about that Martin.Or you can even make 40MHz coz i have 10MHz too here with me.

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: Dc voltmeter 0-55v

Post by medelec35 »

Calculations get a bit scary lol.
What I have worked out that if timer 2 interrupt is set to Pre=1:16 post=1:1 Rollover=29
Timer 2 interrupt frequency will be 17241.379Hz = period of 1/17241.379 = 58ms
If interrupt has triggered 94 times then 58us * 94 = 5.452ms
If interrupt has triggered 95 times then 58us * 95 = 5.510ms
How does that look to you so far?
So if pin is triggered a timer is started and 5.452ms later a pin is set high, then about 250us later pin is cleared back low.
Is that about it?
What is determining if the higher time needs to be used or the lower time?
Need as much detail as possible.
Last edited by medelec35 on Thu May 07, 2020 8:30 pm, edited 1 time in total.
Reason: Changed 58ms to the correct value of 58us.
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Am going to be firing a signal AFTER ac mains zero crossing, so at the falling edge of int0 i will delay that signal with a default FireDelay variable at 5.4788ms which will give me 140v output from the inverse parallel pair of thyristors.So when ever i need to add or sub a 1v from the 140v,on the next falling edge of int0 i will be adding or subtracting a 0.030303ms on or from FireDelay to get 141v or 139v inverse parallel thyristor output.But the 0.030303ms dose not give me exactly 1v increase or decrease but it's close. So from the last flowchat i sent to you shows this clearly my default that i will be using or initial value of FireDelay is 5.4788ms.so my 1v value is 0.030303ms but you can get another one after your calculations as long as it's very close to 1v or 1.16v something so when you get your new value you go to the last flowchat i sent to you,in the calculation box there is where i said enter delay here so you add or sub your new 1v value ( which should be for example arround 0.03...... something) to the default 5.4788ms and place play look at the LCD it should add or sub 1v from the default 140v this should show by how much you deviated away from the 1v. So when ever at the falling edge fireDelay will take action and if am ok with the battery voltage or current I won't add or sub a 1v so FireDelay will take action with it's default but if the prog senses need for change a 1v will be added or sub on every next falling edge until the required value is got.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

And how will Timer2 be enable yet at the time of firing i will be in int0 macro since you told me never to enable an int from another int.Please arange a simple flowchat for me i see it from your flowchat based on the explanation I've just given above.But thank u very much I've just learned how to do interrupt required delay from your example above everything adds some bit of knowledge tho i think 58ms should have been 0.058ms

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: Dc voltmeter 0-55v

Post by medelec35 »

Derrihj wrote:Please arange a simple flowchat for me
Yes I will do do that for you.
Derrihj wrote: think 58ms should have been 0.058ms
You are correct, I did mean to put 58us not 58ms.
Then duplicated it by copy and paste. :lol:
I will edit my post.
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Thanks Martin but did you understand what am trying to do from my explanation above since my English is not all that good? But at the falling edge the signal will be delayed initially 5.4788ms by FireDelay variable, then after that delay it will be switched on for only 250us then off and int is cleared and wait for the next zero cross to repeat the same routine with or without an addition or sub of 0.030303ms to FireDelay variable.

Post Reply