values?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

values?

Post by brandonb »

how do i know what values to write in for the decisions, calculations, variables and such, is there documentation other than what is in the help menu and examples or am i looking over something..... im trying to make a adc input of 0-5v control an led through different decisions, if i understand this right the adc will break down the 0-5 volts analog signal to a digital numbers from 0-255 in voltage increments, how can i use the adc to create different pulsewidth/frequency combinations depending on which voltage the adc is receiving, i wanted to create a bunch of different loops to be able to flow fuel injectors to, i can do all this stuff with electronics easily but haveing issues understanding how to do this with pic microcontrollers using flowcode4 pro.... thanks for looking into this

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

Hello brandonb
That you refer, it remembers me a car engine managed by a modern ECU unit. Please correct me if i am wrong. In modern car engines i know that the acceleration pedal operates a potentiometer (my best friend is car mechanic and i helped him many times :mrgreen: ) which of the output drives the ECU unit and the ECU manages the injectors with pulses. I have seen that lot of times on oscilloscope. For example, when engine runs in iddle the pulses have long intervals, while in "full throtle" pulses are very frequent. You can do this by sure using a microcontroller, for example PIC16F887 has lot of analog inputs (ADC) and 4 ready PWM outputs to manage 4 injectors. Your thought is correct, ADC of micro can convert analog values either in byte format (0 - 255 hex) or in integer format. The converted value is compared with a reference value inside the micro, an internal timer produces repeatedly interrupts and... by some way the difference of comparison is used to modulate the width of a pulse which finally is taken from a predetermined PWM output of micro. The issue is that, i haven't deal with this feature of micros so far but i can confirm you that FlowCode is a "unique tool" with its visual programming interface. It eliminates by 99.9% the need to know a programming language like C or Assembly. Of course you need to study the lot of FlowCode examples, you also should have handy the microcontroller manual, and the Matrix Multimedia tech team (as well many members) will offer you any asistance you need. These are the resources offered. If you have little time left over (say 1 hour/day) to deal with FlowCode and micros, i think that in 2 - 3 months (i take for example myself, i was almost irrelevant with micros before 2 years) you will be able to build any automation you wish.
Regards
Fotis
Best Regards FOTIS ANAGNOSTOU

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: values?

Post by brandonb »

i was searching and hit gold for what i was trying to do this weekend- i used this fella's calculation pid to convert adc to voltage http://www.matrixmultimedia.com/mmforum ... =29&t=8736 that was the missing link to what i was trying to do, if only on the videos from matrix would explain why they put the values in the blanks that they do, im the kind of guy that needs to understand what the values mean so i can use them in other ways or calculate my own ... heres my basic flowbench controller from a pot http://dl.dropbox.com/u/10367218/flowbe ... 2024ms.fcf it has all the important pulsewidth setting with enough off compensated for, will do the math to even out the frequencies later and plan on creating a keypad and 7 segment display somehow in future....also have a cd4000 based counter i designed that can free count and stop based on commanded counts that i can interface with the ra3 pin to stop pulses when bank to bank pulse counts are reached http://dl.dropbox.com/u/10367218/for%20mick/3.JPG thanks for reply, i will do as you say by studying examples, it seem that its a good plan as its panned out so far

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

Nice to you
I forgot :oops: to refer the "Search" window option in the top right corner of "MM user forums" panel. Probably is the best resource. Fortunately, you are smarter than me.
Regards
Fotis
Best Regards FOTIS ANAGNOSTOU

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: values?

Post by brandonb »

Nice to you
what does that mean? ...hey how would i use a tactile to switch between the 45 different presets on the file i showed instead of using the pot, i dont like pots they are touchy
Fortunately, you are smarter than me.
you must be joking

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

brandonb wrote:
Nice to you
what does that mean? ...hey how would i use a tactile to switch between the 45 different presets on the file i showed instead of using the pot, i dont like pots they are touchy
Fortunately, you are smarter than me.
you must be joking
Thanks Brand :D
I will study your fcf later (i already saved it in my HDD), its lunch time in Greece :)
There is also the option of using a rotary encoder, its cost is the same with a good quality tactile switch and works like... 1000 tactiles.
Good afternoon
Fotis
Best Regards FOTIS ANAGNOSTOU

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: values?

Post by medelec35 »

Hi brandonb,
Glad you found my Flowcode useful enough to work from.

I have a few comments.
fotios wrote: There is also the option of using a rotary encoder, its cost is the same with a good quality tactile switch and works like... 1000 tactiles.
I would agree with rotary encoder, but instead of the usual quadrature type, it would be much better to use an absolute (positional) type that uses Gray Code.
Reason being; The quadrature type is mainly used to determine direction of movement, where as absolute type will determine the actual position of the shaft, similar to a pot which can also be used to determine the actual position of the shaft. For Pot you will need the better quality sealed type pot.

The other comments is regarding the Flowchart you have posted.
1) You are using internal osc. It looks like default is 8MHz. Since you have osc speed set to 4MHz, then at the very start of your flowchart you will need to place a C code box with

Code: Select all

osccon=0x60; 
This will force the osc to run at 4MHz
2) If the Voltage variable is greater than 45 e.g 48 then no port C2 output will not be accessed.
Then port C2 will all stay off.
To get around this then you could use

Code: Select all

Voltage >=45 
so if Voltage variable is greater or equal to 45 then port C2 will be high for 20 ms

Attached are the minor corrections.

Martin.
Attachments
flowbench controller 1ms to 24ms V2.fcf
(23.76 KiB) Downloaded 340 times
Martin

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: values?

Post by brandonb »

would agree with rotary encoder, but instead of the usual quadrature type, it would be much better to use an absolute (positional) type that uses Gray Code.
i've never seen one, can you show me the perfect fit with a link to one that i could buy in the usa from digikey/mouser or equivenant,(when it comes to this kind of stuff there are many options) that being said i would probably get the wrong one 5 times in a row
Glad you found my Flowcode useful enough to work from.
dude thank you for posting the comparitor, that was huge help!!, i didnt get a chance to thank you prior to the above
osccon=0x60
Voltage >=45
i wish i understood code?, i tryed to learn assembly last week and decided that i would rather burn the books out of confused rage, i've heard "C" is easier, so even though i set the internal clock with the settings to 4M its really not doing that? the voltage greater than 45 it dont get either, but will check out the v2, as a today project how would it be possible to toggle through the 45 loops with one tactile? i tryed to do the count=count+1 deal but didnt work, how do you come up with the code to fill in the blanks like in the calculation example i used from your comparitor, thanks for the help

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

Hi Brand
Here is a different control method with use of two tactile switches. The first increments values up to 45, while the second decremends values down to 0. I haven't remove the potentiometer on purpose, so you could make a comparison if the thing is working on the same way with switches.
Regards
Fotis
Attachments
flowbench controller 1ms to 24ms V3.fcf
(28.15 KiB) Downloaded 304 times
Best Regards FOTIS ANAGNOSTOU

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: values?

Post by medelec35 »

brandonb wrote: i've never seen one, can you show me the perfect fit with a link to one that i could buy in the usa from digikey
If you search for

Code: Select all

Absolute Encoder
in Digikey, one such encoder is Part No. GH7299-ND
I have not used one of those before, but in theory should be fairly easy to produce a working flowchart for it
brandonb wrote: dude thank you for posting the comparitor, that was huge help!!, i didnt get a chance to thank you prior to the above
Your welcome, not a prob.

Re code:
I have altered flowchart with the suggestions.
as stated previously a c code block with
0sccon=0x60;
(don't forget the semi colon at the end) forces internal oscillator of the hardware to run at 4MHz.
If you use
0sccon=0x70;
That forces internal oscillator of the hardware to run at 8MHz.

Flowcode is a much higher level language than ASM or C, so it's much easier to learn and produce working hardware much quicker.
It's worth studying well.
If I was starting from scratch, I would learn Flowcode (to get working hardware very quickly), then a bit of C, and finally ASM.

Martin
Martin

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

I tried in FlowCode simulator and it seems to work just fine. Thus, i decided to make a last upgrade: 1) I removed potentiometer and 2) I added a 3rd tactile switch so you could RESET counter (COUNT) any time. You should know that variable COUNT has length of one byte, so you can use up to 256 decimal values (0 - 255 d).
Fotis
Attachments
flowbench controller 1ms to 24ms V4.fcf
(27.9 KiB) Downloaded 279 times
Best Regards FOTIS ANAGNOSTOU

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: values?

Post by brandonb »

im confused- what happened to the window with the led in it?

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

brandonb wrote:im confused- what happened to the window with the led in it?
I just deleted the ADC component (i.e. the black knob) because you replied me in a previous post, that you would preffer tactile switch instead potentiometer. I placed two switces instead one to increment and decrement the COUNT and another one to reset the COUNT i.e. COUNT = 0. The variable COUNT is equivalent to the variable Voltage that you used previously with the ADC. Now, ADC does not exists.
We also have to add a display to show the existing value of COUNT (it simply works like an up-down counter e.g. 74HC161) translated in msec. This will offer you a visual indication, so you can read the current setting. The system is working properly but it is "blind" at the moment, i know it. To the present, run the simulator - it runs at a speed of 1000, please don't change it - and press and hold down e.g. B4 (UP) switch. Keep an eye on the "variables window" that opens when simulator starts, you could observe variables changing values continuously.
Fotis
Best Regards FOTIS ANAGNOSTOU

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: values?

Post by brandonb »

i found it- when i opened it up i couldnt find the switches anywhere, they were stuck on off the screen to the right where i couldnt see them, im gonna go through this for a while, i did notice that the switches are real touchy, if i press them for a fraction of a second it shoots from step 0 to step 15, i added a delay but it changed the off time significantly, i want to learn from this so give me some time with it today, i couldnt thank you guys enough for helping me out with this, being a newbie sucks, this simulation has a good amount of learning value in it

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

Here is a most clear version of the last fcf. I have deleted everything useless and i added some debounce (10ms delay) in switches. Hope this time project works correctly. Please, download this file to replace the previous and try it. Tommorow, i will add a LCD display to show the selected milliseconds each time; it is very easy using FlowCode.
Good luck
Fotis
Attachments
flowbench controller 1ms to 24ms V4.fcf
(27.75 KiB) Downloaded 231 times
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

brandonb wrote:im gonna go through this for a while, i did notice that the switches are real touchy, if i press them for a fraction of a second it shoots from step 0 to step 15, i added a delay but it changed the off time significantly
Oh! May i suppose that you are trying the project on actual hardware? If yes, there are lot other modifications for P16F690, this device has big possibilities. You already use the internal precision oscillator module. You could also use the internal MCLR module to get another one pin as I/O and to avoid the use of external R - C for reset during start-up. Internall pull-ups also provided in all pins of Port A and Port B. Enabling them, you can avoid use of external pull-up resistors. In practice, P16F690 can offers 18 pins as I/O and you can connect directly switches in inputs. No need for external resistors, caps, XTALs etc. By enabling the Interrupt On Change state of PortB inputs, will eliminate any bounce issue of switches. Nice choice Brand! :wink:
Fotis
Best Regards FOTIS ANAGNOSTOU

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: values?

Post by brandonb »

alright guys, i had to reverse engineer the last example from scrach studying the example as a guide to make a very basic concept to understand what makes it tick, that is here, that was clever the previous decision of count was stored http://dl.dropbox.com/u/10367218/workin ... counts.fcf i do see problems with this based on hardware testing and looking at the clocked event---> the time it takes in clock pulses and delays to get back to the switch is varyed based on mainly the delayed period, so for instance if there are two setting as outputs a 1 second and a 1 microsecond pulse, then whats gonna happen is your never gonna get more than 1 count of the 1 micosecond pulse because your gonna hold the tactile down for to long of a time and its gonna fire once and by pass to the 1 second, the one second pulse your gonna have to hold the tactile down for much longer period of time, because in the middle of the flowchart is where the decision takes place, if hold the switch down it will shuffle between the counter variables, i was hoping it would be a simple fix that i could put a r/c logic edge trigger on it put then it wont run on the higher pulsewidths, if switch debouncing with delays it actually changes the frequency by allowing more off time,
Internall pull-ups also provided in all pins of Port A and Port B
before i realize my setting were wrong a couple days ago i made all my pins outputs that i wasnt using, is that the same kind of idea, i did see in the datasheet what you were talking about
By enabling the Interrupt On Change state of PortB inputs, will eliminate any bounce issue of switches. Nice choice Brand!
Fotis
can you show me or explain how i could implement that feature, im all ears with flowcode, this is so cool

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: values?

Post by medelec35 »

I believe there will be an issue with counting pulses.
That method will work until power is removed. Then when power restored, you will be starting at 0 value, even for example if the position of the shaft could be 1/2 way round.
That's the reason I suggested using an Absolute Encoder (or to keep it simpler a pot). It will produce a 4 bit value that's determined by the position of the shaft. So when power to the chip is removed, and reapplied, correct position will be given first time.

Martin
Martin

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: values?

Post by DavidA »

Will move this to the V4 forums now brandonb has V4 access!

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

Good morning Brandon and Martin
I am also a bit confused, but with injection time. If i remember well, we talk here for FUEL injectors. Take a look again Brandon at your first post. From those i know from petrol engines, the minimum injection time (in iddle) varies between 2 - 2.5 msec and the maximum (full throtle) between 15 - 20 msec. I don't know any injector that could be activated with a pulse of 1msec! Your max injection times of 5sec to 20sec!!! are also very strange. You could use a solenoid valve YET a common tap instead injector for so big times!
By any way, as i promised you, i have build a new fcf with any assistance offers P16F690 activated. Open the configuration window and take a look on P16F690 config. MCLR is changed to internal module of micro, don't use external R-C to reset the micro, it is executed automatially during power-up. I have removed the OSCCON register C-code command in the beggining, since your Fosc=4MHz is also configured automatically during micro power-up by default (take a look on P16F690 datasheet - internal oscillator). Internal weak pull-ups have been enabled only on the 3 switch inputs. The same for the Interrupt On Change state (IOC) of switches. Switches are ACTIVE LOW, you should solder their terminals on GND rail; there is no need for external pull-up resistors. The IOC ensures no bounces of switches, you should release and press again a switch to take effect. If switch is firmly pressed does not change state and does not cause new interrupt. Click on INTERRUPT icon "Enable PORTB" and in the window that opens click again on "Properties", you will see that IOC interrupts of "RB.4 - RB.5 - RB.6" are configured for OFF state. I added a LCD display that offers visual indication of time selected. It is connected on Ports RC.3 - RC.4 - RC.5 - RA.3 - RA.4 - RA.5 because they found on the same side of micro. You can run the project on simulator, is working just fine although the large times of 5 to 20 sec. Simply you have to wait by holding down the switch until e.g. 20 sec will fulfiled.
You have to make corrections on pulse times, the project is working as it should be.
Fotis
Attachments
flowbench controller 1ms to 24ms V5.fcf
(65.91 KiB) Downloaded 222 times
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

OOps!
I just noticed a strange thing regarding IOC running simulator. Switches cause double interrupt! When are pressed AND when are released. I have seen this for first time, something is going wrong. I will try a small FlowCode to find what is going here.
Fotis
Best Regards FOTIS ANAGNOSTOU

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: values?

Post by Benj »

Hello,

The IOC or PORT type interrupts do exactly as they say on the tin. IOC = interrupt on change. i.e. every change on the port input pins causes an interrupt.

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

Benj wrote:Hello,

The IOC or PORT type interrupts do exactly as they say on the tin. IOC = interrupt on change. i.e. every change on the port input pins causes an interrupt.
I agree, but in PortB interrupt properties window, click --> "Properties" a second window opens "Interrupt On Change Enable RB4/" where i select: "RB.4 Off / RB.5 Off" and "RB.6 Off / RB.7 Off". I had the sence that using this configuration, IOC is configured to triggered ONLY during the falling edge i.e. only when Switch = 0 or when the input is going from HI to LOW state. If i remember well, in my other project (PGA2310 preamplifier) where i use a P16F887 i have not such type issues with IOC, neither in simulation neither in actual hardware. Just now i tried a small flowchart to check the IOC, the same happens, switch cause interrupt when is pressed and when is released.
Fotis
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: values?

Post by fotios »

I found an error on Switch Decisions: "If Switch = 1?" while switch components are configured as "Active LOW", internal pull-ups are enabled etc. So the right decision might be: "If Switch = 0?". I did the corrections, i attach the corrected fcf BUT... the problem of double IOC interrupt still exists! :lol:
Fotis
Attachments
flowbench controller 1ms to 24ms V5.fcf
(65.91 KiB) Downloaded 226 times
Best Regards FOTIS ANAGNOSTOU

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: values?

Post by Benj »

Hello Fotios,
where i select: "RB.4 Off / RB.5 Off" and "RB.6 Off / RB.7 Off". I had the sence that using this configuration, IOC is configured to triggered ONLY during the falling edge
This is disabling the interrupt from these pins and not making the interrupt only work for falling edge situations.

To do this you would have to use a stored version of the port to check to see if a bit has been cleared or set. If the bit has been cleared then you have a falling edge and you can continue with your interrupt.

Post Reply