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:

Re: values?

Post by brandonb »

fotis- i get what the "old voltage <>" pid does by stepping through the program, that freeking genious, it keeps the display from continually updating eliminating flickering... dont know how you thought of that but way cool

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 »

That is! :D
Brand you should know that big part of a correctly working program, is based on programming tricks like the decision "If voltage NOT EQUAL to OLDvoltage?" and Martin's "multiply ADC by 10"--> "divide the result by 100" etc. Like those you did so many times using 555s and other logic ICs. Decisions work like logic gates, using variables and operators we can define the kind of gate.
Here is another example of the last code, i did a modification so that the pwm output be activated once.
Fotis
Attachments
You can do it like this_1.fcf
(16 KiB) Downloaded 285 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 »

fotios- the wiring diagram you posted for the lcd display was a huge help :D

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:fotios- the wiring diagram you posted for the lcd display was a huge help :D
I agree!. That circuit diagram is nice an clear.


Martin
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 »

- can you help me understand this one? and how would i be able to interface the injector drive part after the lcd display- i think this is the key to what im trying to do!
flowbench controller 1ms to 24ms V5.fcf
(67.63 KiB) Downloaded 309 times

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 Brandon.
You have some issues with the last flowchart you have posted.
1) If you compile to hex, you will get a

Code: Select all

failure
Return code = -2
Because the program is too big for 16F690.
So you can either reduce code by making more efficient.
Or Choose a different microcontroller
See:
http://www.matrixmultimedia.com/mmforum ... 201#p22195

Also you have an issue of stack corruption.
This is because the interrupt is calling a macro, which could be called again if switch is pressed again!

I will see If I can help you out, and post an updated flowchart as soon as I can.

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 »

Hi guys
Martin you are right regarding program memory of P16F690, is too small (just 4096 words) for the current flowchart which has a length of 4332 words. I haven't a P16F690 so i compiled this flowchart on a P16F887 with success (only the C command at the beginning that enables individual internal pull-ups should be changed, in P16F690 the related register is named "RABPU" while in P16F887 is named "RBPU"). Using a P16F887 of 8192 word program memory, i had not noticed the length of this flowchart that exceeds the capacity of P16F690. Both 16F690 and 16F887 are of the new PIC generation , and their internal oscillator is factory calibrated and enabled at 4MHz.
As for the message: Serious Warning: Possible sw stack corruption, function 'delay_ms' called by more than one asynchronous thread (main/Task, interrupt, interrupt low) . I can't understand what means that. Using actual hardware (EB006 with P16F887 mounted - LCD board - switch board) i had not noticed any stack problem, the program runs without hang-ups. I used from the beginning internal pull-ups and Port (IOC) interrupt and i had a problem of double interrupt. Port interrupt triggered when switch pressed and when switch released. Benj suggested me to store the initial switches state in a variable to solve the repeated interrupt problem. Following his advice, i led in the given flowchart in which the Port interrupt occurs only when switch is pressed. To cause new interrupt, switch must be released and pressed again.
Looking at the flowchart, you can see that there is no "delay" icon in Main macro, in "SWstate" macro (that is called by Port interrupt) there is only one delay = 5ms, and only in "PWM" macro delays are used in all decision branches. Unless compiller means something different saying: function 'delay_ms'. Really, i don't know.
Let's take a look on the logic of flowchart: The program starts, individual pull-ups enabled, RB.4, RB.5, RB.6 pull-ups enabled and all other disabled, LCD starts and prints "PULSE WIDTH" & "0.0 msec, variable Counter initialize ( = 0) and then flowcode enters in infinite Loop. When a switch is held down, Port interrupt is triggered and calls macro "SWstate". Here is extracted which switch is pressed and the related branch calls macro "PWM". In "PWM" macro variable Counter increments or decrements and the related branch that matches with counter activates the output. At the end of macro, all Switches (state) are cleared and the variable "COUNTupdate = 1". Then, the program flow returns again to "SWstate", and then to main loop where the decision "If COUNTupdate=1" turns the program flow to LCD printings.
Fotis
Last edited by fotios on Sat Sep 17, 2011 5:41 am, edited 9 times in total.
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:- can you help me understand this one? and how would i be able to interface the injector drive part after the lcd display- i think this is the key to what im trying to do!
flowbench controller 1ms to 24ms V5.fcf
Brand do you mean that you want to change the sequence of tasks? In the given flowchart the sequence is:
1) A switch is pressed
2) It triggers the Port interrupt
3) Port interrupt calls macro "SWstate" in which is extracted which of the 3 switches is pressed
4) After switch extraction, is called the macro "PWM" and accordingly counter: a) increments or b) decrements or c) zeroed. Then the injector is activated.
5) Program returns in main Loop, and the value of pulse width is printed on LCD.
We can change the sequence if you want this: Printing of Pulse width on LCD first, and activation of injector after. But this does not make difference in the proccess due to the high speed of microcontroller. All these operations practically are executed simultaneously given the related response time of injectors and LCD printing.
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 »

Good morning from Greece
I did a modification of the fcf file, so it can be fit into the small program memory of P16F690. The actual operation is exactly the same like in the previous fcf, the file is working just fine in simulator and is correctly compiled by FlowCode. The same warning message from compiler appears, i get simillar messages in my other projects when i use Port Interrupt but never i had stack overflow or corruption problems on actual hardware.
Fotis
Attachments
flowbench controller 1ms to 24ms V5mod.fcf
(49.29 KiB) Downloaded 262 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 »

The problem does not has to make with the program code. It has to make with the output of this MAP sensor (Manifold Air Pressure). I have seen lot of MAP sensor diagrams in which the function dP / dV is presented by a straight line that is going increased. If that is true, i.e. the MAP output voltage is a linear function of the pressure change into manifold, then we could invent an equation that would replace this amazing multitude of decisions. Accordingly, and the length of program code.
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 »

I have modified

Code: Select all

flowbench controller 1ms to 24ms V5mod.fcf
So it does the same thing, but all stack warnings are removed, and only uses 46% of the chip space.
So now you have 54% to play with.

I have also changed code so if Port C2 is currently active, then if interrupt occurs its just ignored.
If that needs to be different then please let me know.

What I am confused over is I thought you was using and analogue i/p to determine correct delay, but it's gone to increment or decrement according to which switch is pressed.
We should be able to make hardware work which ever type of detection is required.
Do you want to go back to analogue or keep as current method of detection?

Martin
Attachments
flowbench controller 1ms to 24ms V6mod.fcf
(30.25 KiB) Downloaded 231 times
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 »

What can i say... breathless Martin :shock:
That is a MASTER-PIECE OF PROGRAMMING TECHNIC. And a very good lesson to all of us. I have to study deeper this clever code, nice way to disable double Port interrupts. These "string manipulation" calculations are excellent, i have to study them carefully, it is a nice lesson!
My compliments sir
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 »

Thank you Fotis for those very kind words :)
If my programming techniques (although I admit, not as good as a few people on here) do help anyone to learn something then that's great!

Martin
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 »

hey guys, nice work on the last flowcode martian, im sorry i dont understand the interupts yet, thats my next thing.... i decided to make a couple versions of it, a pot version, and a push button version that doesnt use interupts, instead i use 2 chips, one that does the lcd/injectors and the other one that processes the switch inputs and looks at the injector/lcd pic... its basicly 3 sr flipflops with off delays, when the inj chip follows the command to increment from the switch pic the inj chip sends a micro second pulse back resetting the switch pic configured flipflop so it doesnt count but only one... below is the inj controller flowcode, havent done the swich flowcode yet but its simlple in nature, im gonna add a go to count 1 when it gets to 27 later
Attachments
working on pushbutton flow.fcf
(43.81 KiB) Downloaded 197 times

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 »

here is the switch logic chip- this set up works great with the feedback signals from the other chip that resets the pic configured sr flipflop latches..... port B bit 4 and 5 are the feedback signals for increment and decrement, when i press the tactile in a normal fashion i get one count everytime, if i hold it down i get 5 counts per second with the 180milisecond delay, has good controliblity
Attachments
flowbench switch driver.fcf
(14 KiB) Downloaded 188 times
Last edited by brandonb on Thu Sep 22, 2011 8:54 am, edited 3 times in total.

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 »

in this simple draw up i can make the tactile switches go from 0-4 then when hits 5 it returns back to zero to do 0-4..... how can i make this count back from 0 to 4,3,2,1 when touching the decrement switch but have it start out at 0.0m/s not 4m/s on power up
Attachments
working on latching counts.fcf
(14.47 KiB) Downloaded 188 times

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 »

so is there a such of thing as naming counts below zero, to be able to scroll continious in down count 0 back to 26 26-0 and so on

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:so is there a such of thing as naming counts below zero, to be able to scroll continious in down count 0 back to 26 26-0 and so on
I believe I have done what you asked, but being early I'm not so sure :p

Count will start off at 0, if you press to decrease then count = 4,3,2,1,0,4,3,2,1,0 etc.

Increasing count, then count will be 0,1,2,3,4,0,1,2,3,4,0 etc

I have also added Key mapping to keys. So when running simulation or single stepping simulation works better if you press keys 0 and 1 on your keyboard.

Martin
Attachments
working on latching counts1.fcf
(15.21 KiB) Downloaded 202 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 »

wow the counts below zero start with 255, that was exactly what i was looking for, thanks

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:wow the counts below zero start with 255
Yes that's correct.

With bytes:
If you take 1 away from 0 you get 255 I believe that's called roll under.
If you add 1 to 255 you get 0 which is called roll over.

With signed integers:
If you take 1 away from 0 you get -1
If you add 1 to 32767 you get -32768

Martin
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 »

interesting- you partually answered my next question, what i want to do next is make the counter box that was in the first part of this post, 32,767 is a good number to use to count injection pulses to as a max value, im gonna use my feedback sr flipflop concept to manage the increment values so they would increment on low edge only instead of using interupts.... im guessing the trick to count in integers is to set up inputs as integers instead of bytes, then i could use the same count=0 before loop then count+1 scheme? how would i set the program up to stop on the number i want to select? i know count=the number but i dont understand at this point how to create the program to recognize the number i would input, would it be number= string(0,1) for a calculation or something like that? since i would have a keypad or tactiles to set the number in the second line of the lcd

Post Reply