Help needed!

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

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: Help needed!

Post by medelec35 »

Hi jjw,
jjw wrote:In case very low speed let say less than 100 km/h how to change it into a flowchart?
Since we are using:

Code: Select all

LapSpeed = 10000 / (Speed / 10) * 36 / 10
We need to transpose for Speed when given LapSpeed.
So

Code: Select all

Speed= 360000/LapSpeed
Suppose you want the slowest speed before timeout to be 50Km/h
Then instead of

Code: Select all

Speed < 3000
you want Speed to be:

Code: Select all

360000/50 = 7200
therefore

Code: Select all

Speed < 7200
Since 7200ms over 100mtrs = 50Km/h
At least I believe it is anyway :P
I can check with the formula:
Speed = Distance / Time
Distance = 100mtrs
Time = 7200ms = 7.2 seconds

Therefore speed = 100/7.2*3.6 = 50Km/h

Martin
Martin

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: Help needed!

Post by medelec35 »

Hi jjw,
jjw wrote:Everything is working now very well the only which is not so important but anyway want to mention it is how to make an empty line between different flights. It might be easier to read files this only a small detail. Program works just fine.
Thanks for letting me know.
Glad that your hardware is now logging 10 lap speeds and average speed for 10 laps on USB flash drive.
In answer to your question can you modify your flowchart so the changes are the same as the red stars in the image below:
Extra gap1.png
(15.95 KiB) Downloaded 16784 times
Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
Great thanks to you everything is working now properly after those changes.

Wbr,
jjw

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
Vdrive2 is working fine and all needed data can be read from USB stick. In case I would like to take off the part from flowchart where the txt file will deleted after pushing push button what to do? Have tried out some combinations but not sure if it is enough or do I have to do some more changes?

Wbr,
jjw

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: Help needed!

Post by medelec35 »

Hi jjw, the long press does not delete text file.
It just renamed it so it started from 1 again.
All you need to do is disable or delete the blue from what you sent via pm.
I'm a bit confused from what you stated
jjw wrote:The configuration problem solved. The trick was that I should choose 20 x 4 settings for lcd although I had lcd 16 x 2??? Anyway now it works just fine
Did not know you had a configuration problem?
Just did a search on forums and nothing showed up.
Got no chance of finding it if via pm as there is no search facility.
I don't delete many pm's (except for one's that stat I have been thanked) just in case need for reference but since I have 1989 pm's I try to avoid looking for a particular one unless its very important.
What configuration problem did you have?
You should not need to change to a type of LCD you are not using to sort an issue out.
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Did not know you had a configuration problem?
What configuration problem did you have?
I had only problem with my 16x2 lcd don’t know why. With 20x4 lcd didn’t have any. When I powered it up I could only see blue rectangles….

jjw

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: Help needed!

Post by medelec35 »

jjw wrote:When I powered it up I could only see blue rectangles
Oh I see.
That means LCD has not been initialised.
Odd its initialised with 20x4 and not with 16x2 (which works with my 16x2 LCD)
can you post the flowchart with the issue and I can take a look at it.

Martin
Martin

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: Help needed!

Post by medelec35 »

jjw wrote:Somehow when disabling all blue area shown in my email 17.10.2015 the program needs to have at least 3 pulses when reacting. In standard version the program starts at very first pulse.
Sorry been a away for a few days and just forgot to finish reply.
What about looking at a previous version prior to vdrive.
You can do the loop exactly the same as there is no switch.
If you are still stuck you can post flowchart and I will modify it for you.

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
Here are the results of morning tests. Push button pushed once and given pulse into the sensor. From scope you can see the curve but nothing in LCD. In case waiting some 3 sec and then given new pulse result can be seen in LCD and of course in scope.

jjw
Attachments
sensor.jpg
sensor.jpg (85.32 KiB) Viewed 20483 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: Help needed!

Post by medelec35 »

Hi jjw,
Without more details can't determine what's going on.
First I'm assuming that the switch in question is connected between portB6 and +5V.
There is a pulldown resistor from portB6 to GND.
So B6 is normally low when switch is not pressed?
So we are looking at the green waveform (PortB6 & GND)?
jjw wrote:Push button pushed once and given pulse into the sensor.
There must be a time delay before sensor is triggered after pushing button (I'm assuming top waveform)
At least 1.2 seconds for 300km/h
jjw wrote:From scope you can see the curve but nothing in LCD. In case waiting some 3 sec
Is the LCD displaying Start or Lap0?
Assuming Start?
Can you give as much details as possible please as it saves assumptions.

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

First I'm assuming that the switch in question is connected between
Port B6 and +5V.
Yes and there is 390 R resistor between +5V and switch.
There is a pull down resistor from port B6 to GND.
Yes there is 4.7 k resistor.
So B6 is normally low when switch is not pressed?
Yes it’s low normally.
So we are looking at the green waveform (PortB6 & GND)?
No we are looking yellow waveform since the green one is invert.
Is the LCD displaying Start or Lap0?
Assuming Start?
When switch is pushed it is displaying Lap0. When the switch is not pushed waiting for start it is showing Lap0 and Start

jjw

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: Help needed!

Post by medelec35 »

At the beginning you have start and clear the wrong way around but that should not affect what's going on.
In fact I believe a start is also a clear anyway.
jjw wrote:When switch is pushed it is displaying Lap0
That part is normal.
jjw wrote:When the switch is not pushed waiting for start it is showing Lap0 and Start
I think know why that is.
The switch is being detected as pulled high again 100ms or greater after the initial switch.
Can you set the scope for a longer time period and monitor between B6 and ground.
If that is the case then that is one serious bounce problem.
Monitoring is the only way to find out.
Also I have modified flowchart to display switch count.
So if switch is detected more than once, you should see that on the LCD:
Switch Count Displayed.png
(19.75 KiB) Downloaded 16114 times
Are you ok with modified flowchart being posted on this topic, or would you prefer it to be kept private?

Martin
Martin

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: Help needed!

Post by medelec35 »

jjw wrote:I still want to keep flowchart private.
Jukka
Ok sent you flowchart via pm.
Can you still respond on here please.

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
So B6 is normally low when switch is not pressed?
Just to check that I got it right the resistors are connected as they are in a picture. Is it OK like that?
jjw
Attachments
Active high.jpg
Active high.jpg (6.38 KiB) Viewed 20388 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: Help needed!

Post by medelec35 »

Hi jjw,
Yes that's fine.
V across R2 will be R2/(R1+R2)*V supply=
=10/11*5
=4.5V (when switch is pressed)

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin.
I need more accuracy to show the speed form. It should look like this: 244.8 km/h otherwise the accuracy will be too high. How to do it?

jjw

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: Help needed!

Post by medelec35 »

Hi jjw,
To be honest there is a very little point in its current form of using any decimal places to increase accuracy.
This is because using integers there are rounding errors anyway.
If you want increased accuracy then a different method must be used e.g float variables.
On the big downside, they take up so much room and processing power, depending on target device it may not even be doable.

Martin
Martin

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: Help needed!

Post by medelec35 »

jjw wrote:I’m using MCU 18F442 and look below compiling report. Do you think that my MCU is not enough powerfull:

Memory Usage Report
===================
RAM available:768 bytes, used:90 bytes (11.8%), free:678 bytes (88.2%),
Heap size:678 bytes, Heap max single alloc:127 bytes
ROM available:16384 bytes, used:4042 bytes (24.7%), free:12342 bytes (75.3%)
success
Return code = 0
FINISHED

Wbr
Hi jjw,
18F series with 12K free could be ok.
Won't know for sure until Flowchart is developed.

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
18F series with 12K free could be ok.
Won't know for sure until Flowchart is developed.


Any change that you could help with my accuracy problem?

Wbr,
jjw

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: Help needed!

Post by medelec35 »

Hi jjw,
How many decimal places are you thinking of?
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
One decimal place is enough.

jjw

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: Help needed!

Post by medelec35 »

Hi jjw,
Sent flowchart via pm as you want it kept private.
Gets more complex since floats round to a few decimal places.
I had to place routines to round to 1 decimal place:
Higher accuracy1.png
(99.43 KiB) Downloaded 14982 times
I have not tested this on hardware as not got the time to make the hardware up again.
I would recommend you use the step function and follow how the flowchart works.
Then if you have an issue you will be about to debug yourself,
That help to gain knowledge to enablule you to develop your own flowcharts.

To give you an idea how much Floats can take up.
Your flowchart without ROM uses:

Code: Select all

Memory Usage Report
===================
RAM available:768 bytes, used:91 bytes (11.9%), free:677 bytes (88.1%), 
Heap size:677 bytes, Heap max single alloc:127 bytes
ROM available:16384 bytes, used:4066 bytes (24.9%), free:12318 bytes (75.1%)
With floats added now uses:

Code: Select all

Memory Usage Report
===================
RAM available:768 bytes, used:153 bytes (20.0%), free:615 bytes (80.0%), 
Heap size:615 bytes, Heap max single alloc:127 bytes
ROM available:16384 bytes, used:10596 bytes (64.7%), free:5788 bytes (35.3%)
i.e a difference of 6530 Bytes.Hence me stating if not much memory like the older 16F series then using floats is not recommended or practical depending on initial memory size.

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
Great thanks to you I really appreciate your help. Will test with hardware later.

jjw

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: Help needed!

Post by medelec35 »

no probs.
We need a way of determine how accurate it will be.
Not sure how yet.
Perhaps I could use a stopwatch function of a software simulator to check timing of Speed variable incrementation.
Will let you know
Martin

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: Help needed!

Post by medelec35 »

Hi jjw,
I have noticed that flowchart is set for a clock speed of 19660800Hz.
I will need to know the precise value of crystal you're using.
is it 19.660800MHz or 20MHz?
Or some other value?
Martin

Post Reply