1st project issue/LED-LCD

Forum for problems or queries regarding other Flowcode Components. Eg LEDs, Switches, LCD, Gfx LCD etc

Moderators: Benj, Mods

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

1st project issue/LED-LCD

Post by boa279 »

not new to electronics but new to pic's. Im trying to get an LCD project working with a 16f883 and although it works fine in flowcode I get nothing on LCD. Im starting to think I don't know enough about PIC's and what must be connected. After several hours trying to get it to work (LCD) I gave up and tried the simplest of the simple...make a single led blink with a 16f88. I have an el-cheapo programmer off ebay that must not be compatible with flowcode as I cant auto detect chips...I compile to hex and use my programmer.

I connected vss, vdd (5vdc from 7805) and the single led on port A bit 0....set the clock speed to 4mhz and selected "internal" on the config screen. The led is simply dim and does not appear to blink..somewhere in this forum I read that it may be blinking too fast to be visible so I played around a little but the result is the same. :x What is the bare minimum connections required to get my blinking led to work correctly.

I want to get it right with the simple projects so I can give my lcd project another wack. BTW the LCD project shows only dark boxes on the top row of the lcd and nothing else happens. Im trying to use the internal oscillator of the 16f883 set to 4mhz. Im positive its something Im doing wrong with the physical connections on the project itself...Im either not connecting everything I need to be or my knowledge of oscillators is too limited. Whats the difference between clock out and no clock out? both flowcode and programmer have internal I/O or something to that effect. I know once I get one thing to work I wont have problems from there...PLEASE HELP AND THANKS IN ADVANCE!!! :mrgreen:

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: 1st project issue/LED-LCD

Post by Benj »

Hello

You are right about your LED flashing program that is the best way to get the device working correctly.

1) Set you clock speed in Flowcode - This sets the length of delays etc relative to the device clock. Chip -> Clock Speed -> Set to 4000000

2) Set your oscillator configuration in Flowcode - This configures the chip into the correct mode. Chip -> Configure -> Set to Internal

3) Start your Flowcode program with a while 1 loop

4) Inside the loop add two output icons, 1 to output 255 to a port and 1 to output 0 to the same port.

5) Add 2 delay icons to the while loop in between the output icons. Set the delays to use 250ms.

6) Compile your program and send to the device.

You should hopefully see a port flashing on and off twice a second.

Also are you powering the MCLR pin. You will need to provide power to this from your 5V connection via a 1K resistor. Alternativly you can change the chip configuration to use the internal MCLR if your chip supports this.

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

Good points! I wish there was a way for flowcode to draw a simple schematic so you dont have to go clicking through each component to find what port and bit everything was on...would also be helpful to see the MCLR pin connected to vdd with a 1k... Also, you mentioned something else of interest. I completly understand how to make the programs and have a few complex ones working already...but I didnt know to output 255 for high. I always use 0 and 1 which I thought would be logic 1 and logic 0. Does that mean I can control the brightness by adjusting the bit anywhere between 255 and 0? THANKS AGAIN!!!

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: 1st project issue/LED-LCD

Post by Benj »

Hello

Ok 255 is an 8-bit value which equals 8 logic 1s or an entire port. See conversions from decimal to binary. You can control the brightness by switching the output on and off at high speed. See my example for bit banged PWM.

http://www.matrixmultimedia.com/Flowcode_Examples.php

As for your schematic idea I think that is being developed for version 4.

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

I want to punch myself in the face....I can't beleive Im unable to get this working. I have 1 led connected to A0 on pic 16f88. Program blinks led every second (500 ms on 500 ms off) program works perfectly. Pic is physically connected to vdd, vss and MCLR is connect to vdd. Oscillator is set to internal...clock set to 4mhz. I cant figure anything else out. Program is awsome but getting it to work in reality is driving me crazy. What am I doing wrong. Also, what programmers will interface with flow code directly for programming? Thanks

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: 1st project issue/LED-LCD

Post by Steve »

Are you still having problems with flashing an LED? If so, you could try posting your program here for someone to look at.

If it's the LCD that's not working, you may have forgotten to use the "Start" macro to initialise the LCD.

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: 1st project issue/LED-LCD

Post by Benj »

Hello

For programmers that will interface directly to Flowcode you could try any one of the following.

EB006 - Multiprogrammer board
HP488 - Development board
ECIO - Low cost USB dongle board - I think the experiment kit for this has just come down to Β£29 which includes the programmer board.

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

bought this programmer ( HP488 - Development board)...love the e-blocks concept so figured this is the way to go. Still having issues with both projects and I know it must have something to do with the clock settings or how Im physically connecting the pic's on the breadboard.

User avatar
goldwingers
Posts: 118
Joined: Wed Sep 06, 2006 1:22 pm
Location: London
Been thanked: 1 time
Contact:

Re: 1st project issue/LED-LCD

Post by goldwingers »

Hi Boa,
If i read your posts correctly you have the ver3 development board. (HP488). I further assume that the program runs on the development board?. but when you take it to a prototye it does not run. If so i feel certain that the internal clock is not running. The development board uses an external oscillator for the chip. I have tried to use the internal osc feature on an 88 chip and i could not get it to run either.

Try using an external osc on your board. I use a general purpose prototyping board and have a section with a crystal and caps set up to use.

Regards

Ian

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: 1st project issue/LED-LCD

Post by Steve »

I've had the internal oscillator for this chip working, so I know it can be done. There are plenty of posts about this, so you should do a search for "osccon" or "internal oscillator".

For example, here's a very early post about this topic:
http://www.matrixmultimedia.com/mmforum ... sccon#p241

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

steve wrote:I've had the internal oscillator for this chip working, so I know it can be done. There are plenty of posts about this, so you should do a search for "osccon" or "internal oscillator".

For example, here's a very early post about this topic:
http://www.matrixmultimedia.com/mmforum ... sccon#p241
THANKS!!! With this informative link I was able to get my led blinking correctly! I applied this to my LCD project and got a whole lot farther than I was. I now have a bunch of random symbols on my Lcd!!! Not the way Its supposed to be but Im getting somewhere now! I will do a search and see what I can find but any help appreciated. I also have an interupt which turns an led on and off if the switch is held for 2 seconds...this part works perfectly...just have to get the characters to display correctly and Im set! Thanks a lot for the help!

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

LCD update: So, I tore down my breadboard and rebuilt it to make sure everything was correctly connected. As far as I can tell its all right..I will have to throw a schematic together and post it so other more experienced people can see what Im doing. Im using a 16f883 and I have the EB006 programmer. Im trying to use its internal oscillator (set at 31,000 Hz in config screen per the 16f883 datasheet, page 63) but I dont get the "internal" option that I used to get with a 16f88. I get RC, EXternal and something else. (dont have it in front of me.) The lcd starts up but I get random sysmbols like &___? > ?......not the text Im trying for. Im also using an inturpt which turns and led on if I hold a button for 2 seconds. This part works perfectly so Im thinking the oscillator part is working..What would cause the random characters? Im thinking some of the settings are wrong in the config screen. Can someone give me a hint ;) Ive searched everywhere but cant find anything thats helping me. THANKS!!!

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: 1st project issue/LED-LCD

Post by Steve »

One possibility is you have LVP set on in the configuration word. This will prevent B3 (I think) from functioning as an i/o line. If your LCD uses this pin, you may see unwanted characters appearing on the display.

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

I see nothing but unwanted characters and even though I use both lines of the LCD the characters are normally on the top line (normally)
I will look at the LVP but I think Ive tried it both ways because I read about that in another post...Thats why I started using the external power supply. Also, How do you write characters in flowcode like the solid block character (11111111)???

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: 1st project issue/LED-LCD

Post by Steve »

I think the solid block is within the default character set of the LCD module - have a look at the datasheet for the driver chip for more info.

If not, you can create custom characters. I have created an article about this in the "articles" section of the forum.

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

I know its in the default list of characters but how do I use the ones that are not "on the keyboard"....what would I have to put in flowcode to have the lcd display that character?

Print " ??????????"

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: 1st project issue/LED-LCD

Post by Steve »

Use the characer code number. For example, instead of 'A' you could use the number 65.

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

where did you find that code?

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: 1st project issue/LED-LCD

Post by Steve »

The code for the characters will be in the datasheet for the display driver chip.

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

SUCCESS with the 16f88 and LCD! Osscon set to 8mHz, typed 8000000 in flowcode, LVP off eb006 connected to 13.5vdc power supply! Still cant get the 16f883 to work though...also using osccon 8mHz, 8000000 in flowcode, lvp off...but I dont have the option for "internal I/O" in expert config. Whats the problem? I can pick "internal RC" but looking at the data sheet it should have the same type internal osccilator as the 88...what am I missing?

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: 1st project issue/LED-LCD

Post by Steve »

Remember to include the C code "osccon=0x70;" to set it to 8MHz.

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

steve wrote:Remember to include the C code "osccon=0x70;" to set it to 8MHz.
Thats how I got the 16f88 to work...tried the same thing with the 16f883 but no dice...why dont I have the "internal I/O" option under oscillators in the expert config with the 883? Im having to choose "internal rc" because thats the only internal option...im thinking thats the problem.

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: 1st project issue/LED-LCD

Post by Steve »

See options below...
Attachments
config 883.jpg
config 883.jpg (75.46 KiB) Viewed 16748 times

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

Thanks Steve...I will give that a shot when I get off work!

boa279
Posts: 38
Joined: Mon Sep 15, 2008 11:47 pm
Contact:

Re: 1st project issue/LED-LCD

Post by boa279 »

So here is an update...this is so frustrating. I can get a 16f88 to display text correctly ONLY if the clock is set at 31250 and oscilator to "internal I/O"
With this configuration it will display what I want almost perfectly...almost because every now and then a letter or two changes. If the text is "This is a test" with a 2 second delay, it might show that 3 times but on the 4th time it might say "This is T test" or "Th8s is a test". Whats really screwing everything up is when I add anything other than the lcd...like a single switch to RA1. When this happens the lcd either doesnt work at all or just puts garbage on the display. I also noticed when I use the osccon for clock it gets even more inaccurate..."T*ut yu a te%5" and the 2 second delay is no longer 2 seconds it like half a second.
Here is my setup...maybe Im doing something wrong. Im using a single 7805 to power everything...not sure if that could be causing problems. It powers the lcd, lcd backlight the pic and any buttons im tring to use. Im also removing the pic from the programmer each time and puting it on a breadboard. I was still unable to get the 16f883 to work using the settings above...however I did not try to use just the lcd like I did with the 88. What do I need to post or send for you guys to look at. Im getting too frustrated. Flowcode is amazing and I have several complex programs working without a hitch...just getting to work "off the screen" is a nightmare at the moment.

Post Reply