Having trouble turning on LED?

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Werner
Posts: 95
Joined: Sat Jun 11, 2011 4:12 am
Has thanked: 87 times
Been thanked: 31 times
Contact:

Having trouble turning on LED?

Post by Werner »

I just got Flowcode Pro and can do some fun stuff in simulation but can’t get anything to work on my bread board? For example the Lighting an LED.FCF in the example file. I have a 12F629 with this programmed into it with +5 at pin 1, ground at pin 8, LED and resistor to pin 7 then ground. It seems simple but I am new to this and know I am missing something? I did set the clock speed to 4000000 but no luck.
Thanks for the help!
Werner
Werner
STUDENT OF: Martin - Professor of Flowcode, John, Jan, Fotios and Nicolas "Spanish Dude"

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: Having trouble turning on LED?

Post by medelec35 »

Hi Werner,
If you are using the internal osc, have you set this option up in the configuration settings. I always use Expert Config Screen.
To do that (go into the configuration menu ('Chip Configure..') click on 'Switch To Expert Config Screen')
Once there you can change to internal osc.
There could be 3 reasons why your LED is not working.

1) Internal oscillator not selected in configuration settings.

2)Master Clear Enable is set to external (also in configuration settings)
If set to External, there should be a pull-up resistor connected between GP3 and +5V. The idea being a switch is used to short GP3 to 0V when to want to restart the chip.
If GP3 is at 0V all the time (in the case of no resistor) then program will never run
If this is the case then either change Master Clear Enable to internal or use a pull-up resistor.

3) Program or configuration settings are not getting transferred to chip. How are you programming chip on the bread board?
Via ICSP?
Has your programmer confirmed program has been successfully transferred?

I can check to see if your configuration settings are contained within the hex file.
If you check the configuration settings within Flowchart are correct, then recompile and program your chip,
If still does not work you could post the hex file on your next post.
I can then check the settings for you.

I have configured attached Flowchart to flash LED connected to GP0 at 1Hz
Good luck.

Martin
Attachments
Flashing LED.fcf
(4.5 KiB) Downloaded 385 times
Martin

Werner
Posts: 95
Joined: Sat Jun 11, 2011 4:12 am
Has thanked: 87 times
Been thanked: 31 times
Contact:

Re: Having trouble turning on LED?

Post by Werner »

Hi Martin,
Thank you so much!! I will try the things you mentioned and let you know the results. I am using a USB Microchip PIC Programmer (JB3 Chip Burner)
from KEE electronics. It has worked great for me in the past and seems to be programming the hex from FC OK.
Werner
Werner
STUDENT OF: Martin - Professor of Flowcode, John, Jan, Fotios and Nicolas "Spanish Dude"

Werner
Posts: 95
Joined: Sat Jun 11, 2011 4:12 am
Has thanked: 87 times
Been thanked: 31 times
Contact:

Re: Having trouble turning on LED?

Post by Werner »

Hi Martin, I gave it a try but LED just stays on... no flashing. Here is a copy of the hex that I used. Thanks again for the help I can see I have a lot to learn....
Attachments
Flashing LED2.hex
This is the hex file I tried
(668 Bytes) Downloaded 260 times
Werner
STUDENT OF: Martin - Professor of Flowcode, John, Jan, Fotios and Nicolas "Spanish Dude"

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: Having trouble turning on LED?

Post by medelec35 »

Hi Werner,
I can see why the LED is on all the time. Just looked at your hex file and the problem is still caused by your configuration settings.
You have got watchdog enabled.
LED is switching on then after about 18ms chip is resetting so cannot reach led off command,
since there are no clear watchdog commands to prevent chip form resetting.
have a look at this picture:
Config Settings 12F675.jpg
(167.19 KiB) Downloaded 1792 times
Top is the correct configuration for your set up, and lower is your set up which has the time-out problem causing LED to look like it stays on.

You can check config settings yourself from a hexfile by running PPP.
Make sure you select 12F675 first.
Click open then load hexfile.
Click 'View' then select 'View HEX File'
Finally click on 'Config Screen'
Then you will see the normal ppp config screen which shows the config settings.

Martin
Martin

Werner
Posts: 95
Joined: Sat Jun 11, 2011 4:12 am
Has thanked: 87 times
Been thanked: 31 times
Contact:

Re: Having trouble turning on LED?

Post by Werner »

Yippeeeee!! Thanks Martin!! It’s funny how a little blinking LED can make me so happy! You kinda lost me with running PPP? But I did try my other programs and they are all working now too! LED's blinking all over my breadboard now! :mrgreen:

Werner
Werner
STUDENT OF: Martin - Professor of Flowcode, John, Jan, Fotios and Nicolas "Spanish Dude"

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: Having trouble turning on LED?

Post by medelec35 »

Just glad your up and running now. :)
Werner wrote: You kinda lost me with running PPP? But I did try my other programs and they are all working now too!
Normally you don't need to run PPP on it's own since Flowcode will transfer the correct settings to chip, so long as correct setting are set within the configuration screen the the first place :P

PPP software is what Flowcode PIC version uses for programming the microcontrollers.
If you select Chip then configure menu Within Flowcode, then the new window that pops up is apart of PPP software.
From the expert configuration you set the configuration of the microcontroller. e.g disable watchdog, low voltage programming etc.
While the configuration screen is up It's a good idea to make enable expert configuration screen show as default.
Just click on options and un-tick use simple config screen.

Going back to the previous post of ppp, I should of said how to run it independently of Flowcode.
Sorry about that.
If there is no shortcut,If using Flowcode V4, ppp can be be found within C:\Program Files\Matrix Multimedia\Flowcode V4\Tools\PPP
Using a file manager right click PPPv3 application and select send to, then desktop (create shortcut)
Now ppp is on your desktop you can run it from there.
You could now follow the instructions on previous post to load existing hex and check config settings.
Martin

Werner
Posts: 95
Joined: Sat Jun 11, 2011 4:12 am
Has thanked: 87 times
Been thanked: 31 times
Contact:

Re: Having trouble turning on LED?

Post by Werner »

I get it now Martin! I did make the change to default to expert configuration, good idea.
Thanks again for all your help!
Werner
Werner
STUDENT OF: Martin - Professor of Flowcode, John, Jan, Fotios and Nicolas "Spanish Dude"

Werner
Posts: 95
Joined: Sat Jun 11, 2011 4:12 am
Has thanked: 87 times
Been thanked: 31 times
Contact:

Re: Having trouble turning on LED?

Post by Werner »

It appears that the 12F629 chip pin 4/ GP3 is not usable as an output if I have configuration set to Master Clear Enabled- Internal? Am I right in thinking this?
Thanks for the help Buddy!
Werner
Werner
STUDENT OF: Martin - Professor of Flowcode, John, Jan, Fotios and Nicolas "Spanish Dude"

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: Having trouble turning on LED?

Post by medelec35 »

yes you are correct.
When set to internal, MCLR pin is input only.
I have never seen it as an output.
There are some devices that you can't use MCLR as I/P, but yours is not one of them.

If you want an 8 pin device to play with. I would recommend one with analogue i/p's as well.
e.g. 12F615. Which also has PWM.

One thing I noticed, in the pass I used a 12F675, so automatic mode kicked in, and I set PPP to that device instead of 12F629.
Sorry about that. I just had a Muppet moment.

Martin
Martin

Werner
Posts: 95
Joined: Sat Jun 11, 2011 4:12 am
Has thanked: 87 times
Been thanked: 31 times
Contact:

Re: Having trouble turning on LED?

Post by Werner »

Sounds good Martin, analogue i/p's it the next thing I want to play with! I will order a few of the 12F615's. I just can’t get over how cheap these little suckers are! It boggles my mind the possibility’s available to me now.
Werner
STUDENT OF: Martin - Professor of Flowcode, John, Jan, Fotios and Nicolas "Spanish Dude"

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: Having trouble turning on LED?

Post by medelec35 »

Before you order any devices, If I was you I would look at this page first:
http://www.matrixmultimedia.com/mmforum ... 40&p=22195
It could help you select a better device.
If your having just having a play with Flowcode, it's so powerful and there are so may different things you can do with it.
Next you will discover the chip has run out of space. so rather than 12f675 select a chip you could connect an LCD, & keypad, driving EC motors direct via PWM ect.
Before you know it the "I want to do much more and stretch this device to the full" bug sets in :)
I would say minimum would be 28pin device. If choice of 28 pins then order the one with most memory/functions available.
You could then use the cheaper devices as a permanent device in any project you would like to keep.

Tip: If looking for a better device, create or download a working Flowchart. Change target to the device your interested it, to see if it supports the microcontroller and compiles ok.
Alternately this marketing sheet explains more, and lists supported devices.
http://www.matrixmultimedia.com/datashe ... 4-60-7.pdf
When you get your new device, Help is always at hand. There are loads of resources including youtube videos for creating projects with Flowcode.
This would be a good starting place:
http://www.matrixmultimedia.com/flowcode.php
and
http://www.matrixmultimedia.com/sup_menu.php
Good luck.

Martin
Martin

Post Reply