4 button latchin project

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

Post Reply
jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

4 button latchin project

Post by jbs4wd »

Hi
I have just purchased flowcode and loving it. Upgraded to 4.2.
I have a problem tho. Although I have made up a program and it simulates perfectly, when I down load to the PIC (16F690) via the pickit2 it doesn't work in real life. The initial setting comes on and that's it. Also the HVY button input by the looks of it has turned itself to an output an turned on (You will see what I mean by HVY button when you see the project).
I have set the programming etc settings as layed out in this formum before to use the pickit2, so any help info would be of great help.
Thanks
John
Attachments
4button1.4.fcf
(24.48 KiB) Downloaded 300 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 4 button latchin project

Post by medelec35 »

I believe can see several things wrong.

1) you are using internal oscillator (looking at your config settings) but you have not place a C box at the beginning of main with osccon=0x70;
this will set internal oscillator to 8MHz. Othwise I believe the default frequency will be 4MHz

2) You have set the oscillator speed in flowcode to 10MHz. This should be at the same speed as frequency of chip i.e 8MHz.

3) You are using a rising edge interrupt, but your interrupt macro has nothing in it.

General advice would be: Make 1st project simple flashing LED at about 1Hz. then you will know all your configuration settings are correct, and oscillator is running at correct speed.

Try this attachment.

Hope it helps.
Attachments
4button1.4_Moded.fcf
(24.54 KiB) Downloaded 332 times
Martin

jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Re: 4 button latchin project

Post by jbs4wd »

Thanks medel,

I will give it a try as soon as I get my bloody pickit working again. It just had a hernia and OS stuffed up in it. I will let you know how things go.
Thanks again

jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Re: 4 button latchin project

Post by jbs4wd »

Got the bloody pickit working.
I actually forgot about the interupt macro. I don't think I will need it just yet so I got rid of it.
However is still doing the same. staying on with HWY LED ON, HVY LED ON, HWY/HVY LED ON. But what gets me though is why an input pin is being turned on? (HVY PIN and OFF PIN(only on half though???!!!!!2.8V)
I have added the msg after I compiled maybe someone can make heads or tails of it.
Also I know I should be doing small projects first but this came up and I need to get to work quickly. do jump in the deep end sometimes.

Thanks again
Attachments
4button1.4_Moded.msg.txt
(3.32 KiB) Downloaded 279 times

jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Re: 4 button latchin project

Post by jbs4wd »

I have just found another anomaly (spell???????) in the C code view.

#ifndef MX_ADC_TRIS_REG
#pragma error "ADC Type 3 conversion code error - please contact technical support"
#endif

This happens a couple of times. What does this mean and how can it be fixed.

I have added the C code view file to look at to see if anyone can sort this out.
Thanks again

JOHN
Attachments
4button1.4_Moded.c
(21.73 KiB) Downloaded 299 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 4 button latchin project

Post by medelec35 »

I see what you mean. I did not look into that because you said your simulation is working correctly.
Anyway the problem you have is the masking. You have ticked the ports you want to have effect on, the unticked ports will not be affected.
So if you have ports C 0, 2, 4 & 6 ticked then if you 0 as variable then only ports C 0, 2, 4 & 6 will be cleared.
C 1 ,3, 5 & 7 will be ignored.

Also the 1/2 voltage is because of not steady stage. your meter is picking up the average of on/off. so your port is rapidly changing. Don't forget in your configuration you have it set for 'Internal RC Clockout' so your meter is probably measuring this clockout. Try changing your config to internal RC no clock.

To debug your code, just press F8 key, right click in variable window, select add variable, then select variable you want to add.
Keep pressing F8 to single step though your code.

Another thing I have noticed, is after changing the masking ticks, for your C port and re running, as soon as HWY , HVY and HWY/HVY LEDS go off, they are back on after 2 seconds when your program loops. even with button held down.

Also I don't think its a good idea to have the clear button bit. If you push button so is held high, then you are forcing it to an out put, so it low. If you have no pull up resistor, the max allowable current will flow though this port (although for a short time)

If you post a description of want you want your program to do, then can help you further.

I believe the error text you see is part of a decision routine and is use to flag up error messages in event of a problem which is then shown in the compiler message window. Since the message not appear in the window, you can ignore the text within the C part.
Martin

jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Re: 4 button latchin project

Post by jbs4wd »

I was looking at the clocking. Thanks. Will fix up what you sujested and see how we go.
Here is a description of what the unit has to do as you asked.

INFORMATION

WHAT HAS TO HAPPEN.
ON START UP, HWY LED & HEVEY LEDS ARE ON, HWY/HVY POT IS ON, THE REST IS OFF.
HWY & OFF ROAD BUTTONS TOGGLE BETWEEN EACH OTHER, & HEAVY & LITE BUTTONS TOGGLE BETWEEN EACH OTHER.
IF HWY & HEAVY ARE ACTIVE, HWY/HVY POT IS ON ONLY
IF HWY & LITE ARE ACTIVE, HWY/LITE POT IS ON ONLY
IF OFF ROAD & HEAVY ARE ACTIVE, OFF ROAD/HEVEY POT IS ON ONLY
IF OFF RAOD & LITE ARE ACTIVE, OFF ROAD/LITE POT IS ON ONLY

WHEN OFF ROAD BUTTON IS PUSHED, HWY LED OFF, OFF ROAD LED ON.
WHEN HWY BUTTON PUSHED, HWY LED ON OFF ROAD LED OFF.
WHEN LITE BUTTON PUSHED, HEAVY LED OFF, LITE LED ON.
WHEN HEAVY BUTTON PUSHED, HEAVY LED ON, LITE LED OFF

ADC
IF SPEED SENSOR RISES ABOVE GPS SET PIC GOES TO START UP THEN BUTTONS CAN BE USED
IF SPEED SENSOR IS AT 0 FOR 10 MINUTES, PIC GOES TO START UP THEN BUTTONS CAN BE USED



I hope this is clear enuf for you.

Thanks again

JOHN

Post Reply