Like to read Port B then send to Port D

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

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4362 times
Contact:

Re: Like to read Port B then send to Port D

Postby Benj » Wed Oct 01, 2014 10:32 am

Hello,

There is a LCD wiring guide here which should help.
http://www.matrixtsl.com/wiki/index.php ... 954a4191ea

I really like these to look at but they are a fair bit more expensive then the bog standard models.
http://www.adafruit.com/products/399
These users thanked the author Benj for the post:
JLeith (Wed Oct 01, 2014 4:29 pm)
Rating: 5%
 

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Wed Oct 01, 2014 4:32 pm

Hi Benj

I have printed off the LCD Wiring Guide

Benj why would that LCD cost $13 over the Futurlec $9 unit

Very puzzling

John

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Wed Oct 01, 2014 4:44 pm

The PiC 16F1937 has just arrived.

jump happy.jpg
jump happy.jpg (5.9 KiB) Viewed 7143 times


I will start building the breadboard later this afternoon

I will add in the PICKit 2 interface and I hope it will work.

This is what I have found on the net
Attachments
PIC Programming.jpg
PIC Programming.jpg (28.1 KiB) Viewed 7143 times
These users thanked the author JLeith for the post:
Benj (Wed Oct 01, 2014 4:52 pm)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4362 times
Contact:

Re: Like to read Port B then send to Port D

Postby Benj » Wed Oct 01, 2014 4:46 pm

Hi John,

Benj why would that LCD cost $13 over the Futurlec $9 unit


I think it's down to how the characters are displayed and how much of a cut the middle men are taking.

The bog standard units use liquid crystal to give you a very standard display.

The next one's up have a backlight to light up the display.

Then moving up again you have displays with better LED backlights (lower power and better diffused light).

Then you have displays which use lit characters, I think they are based on proper 2D matrices of LEDs but provide the standard alphanumeric LCD interface to keep things simple. These are the adafruit one's I pointed out.

I think there is also vacuum fluorescent based versions of the displays too. These look really nice.

You then get OLED where the LEDs have been grown in position in a lab using lasers and other magic rather then being assembled. These give you very good pixel resolution.

Obviously if you buy direct from China then you will likely get a much better price then buying from a supplier in the UK/Europe but you might have to wait for delivery and there could potentially be hidden customs issues. I've personally had to go down and pay extra to the customs department a few times when the Chinese have decided to send something and marked it as a "gift" when it obviously isn't.

Prices on eBay are all over the place so do shop around b4 committing to the sale.

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4362 times
Contact:

Re: Like to read Port B then send to Port D

Postby Benj » Wed Oct 01, 2014 4:54 pm

I will add in the PICKit 2 interface and I hope it will work.

This is what I have found on the net


That diagram you posted looks wrong to me, unless it's not meant to be in order. The PICkit interface should run like this.

1. MCLR
2. VCC - +V Supply
3. VSS - GND
4. PGD
5. PGC
6. N/C

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8826
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2561 times
Been thanked: 3721 times
Contact:

Re: Like to read Port B then send to Port D

Postby medelec35 » Wed Oct 01, 2014 8:45 pm

Hi John, don't forget the 10K resistor (not shown on the diagram) between VPP of programmer and VPP of 16F1937.
Without current limiting, 16F1937 could get damaged.

Martin
These users thanked the author medelec35 for the post (total 2):
JLeith (Wed Oct 01, 2014 11:59 pm) • Benj (Thu Oct 02, 2014 2:08 pm)
Rating: 10%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Wed Oct 01, 2014 11:58 pm

Thank you Benj for the correction I will investigate.

Martin I don't recall the 10K on the VPP or Pin 1 of the 16F1937 I will double check.

John

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Thu Oct 02, 2014 12:12 am

I think I have it this time

I was surfing the net an found the 10K.

Is this correct ?

John
Attachments
PIC Programming with PICKIT.jpg
PIC Programming with PICKIT.jpg (51.5 KiB) Viewed 7127 times
These users thanked the author JLeith for the post:
Benj (Thu Oct 02, 2014 2:09 pm)
Rating: 5%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8826
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2561 times
Been thanked: 3721 times
Contact:

Re: Like to read Port B then send to Port D

Postby medelec35 » Thu Oct 02, 2014 7:32 am

If it's for a device like 16F887,16F88,12F675 etc, programming VPP is is specified as between 10 and 12V.
This is what the vpp will be on pickit2, so the circuit above will apply if you have external MCLR which is not necessary if say a reset switch is not required then 10K from VPP to +5V is not required.

If using 16F1937, 16F1827, 12F1840 for example which are the newer type of devices, Microchip has dropped the VPP programming voltage from 10 - 12V to 8 - 9V
So if using pickit2 which does not alter VPP voltage to suit, then it can cause damage to the newer devices.
So I place a 10K resistor between VPP of programmer and VPP of microcontroller when using a pickit2 to limit the programming current to a safe level for the target device.
So if MCLR is set as internal no resistor is required from VPP to +5V

If you wish to enable MCLR and connect a reset switch from MCLR to GND, since MCLR and VPP are shared, you will need an additional 10K resistor going from MCLR/VPP to +5V as well. Or you can use a diode of course.
Hope that helps to clear things up.
When designing the PCB make sure get ICSP connections in the correct order (Just like Ben has pointed out)
The last circuit diagram is the correct order for pickit2.
These users thanked the author medelec35 for the post (total 2):
Benj (Thu Oct 02, 2014 2:09 pm) • JLeith (Thu Oct 02, 2014 5:13 pm)
Rating: 10%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Thu Oct 02, 2014 5:38 pm

Hi Martin,

Thank you for the info on the VPP.

When I programmed the Main Control panel which has the 16F1827 I didn't put in the 10K resistor and programmed it on a breadboard with the PicKit 2 then placed it in the PCB board.

I don't believe I will need a reset on the MCLR so it can be made internal. Were do I place the code for MCLR to be internal ( Main Page ?)

Here is the new PCB layout

I have ordered the LCD from Futurlec (LCD16X2) order a 16X2 without out back lite and 1 with back lite seeing I have never used them I would try both
I was very happy to see they only charge $4 to ship ( 2.2 GBP )
On the LCD I connected the following DATA leads
PIC -- LCD
A0 --- PIN 11
A1 --- PIN 12
A2 --- PIN 13
A3 --- PIN 14

The RS and Enable were straight forward.

I will wait for your email before I program the PIC with the PICKIT2 to ensure I have the VPP correct.

Martin on the Port C 0 - The Main board is sending out +12 now I think I should place a relay to detect the + 12 and send +5 to PORT C 0 ?

John
Attachments
PIC Programming with PICKIT VPP.jpg
PIC Programming with PICKIT VPP.jpg (49.23 KiB) Viewed 7105 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8826
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2561 times
Been thanked: 3721 times
Contact:

Re: Like to read Port B then send to Port D

Postby medelec35 » Thu Oct 02, 2014 6:29 pm

JLeith wrote:Were do I place the code for MCLR to be internal ( Main Page ?)

No you don't place any code to change MCLR from default external to internal
You need to enter configuration options ('Build', 'Project Options') then select 'Configure Chip'

You will need to change MCLR pin function select to Disabled.

JLeith wrote:I will wait for your email before I program the PIC with the PICKIT2 to ensure I have the VPP correct.

Yes that looks correct to me.
It's always recommended to place a 100nF cap across the +5V and GND of microcontroller

JLeith wrote:The Main board is sending out +12 now I think I should place a relay to detect the + 12 and send +5 to PORT C 0 ?

Alternatively you could do this:
Potential Divider.png
Potential Divider.png (4.43 KiB) Viewed 7100 times

More cheaper, reliable and uses much less power than a mechanical relay.
These users thanked the author medelec35 for the post:
JLeith (Thu Oct 02, 2014 10:23 pm)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Thu Oct 02, 2014 10:37 pm

Martin your a wizard.
Wizard.jpg
Wizard.jpg (5.99 KiB) Viewed 7094 times


Thank you I will modify the PCB with the divider. Never occurred to do this.

I will hopefully build the Bread board and load the PIC today.

Martin have you come across a program that I could use to build a complete electrical drawing for my project. I have about 6 drawings of each step and would like to put it all together as 1 drawing. Mot of the ones I have found are focused on PCB. I have seen blogs with drawings for Android circuits but no links ?

I would like to send you a video of the working project but it comes out as 17meg to big to email.

John

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8826
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2561 times
Been thanked: 3721 times
Contact:

Re: Like to read Port B then send to Port D

Postby medelec35 » Thu Oct 02, 2014 11:38 pm

Hi John
JLeith wrote:Martin your a wizard.

I wish :lol:
Thanks anyway :)
There are two good packages that are totally free
1) TinyCad
&
2) Designspark PCB.
You will need to register to use Designspark, but its a full free schematic capture and pcb design package.

JLeith wrote:I would like to send you a video of the working project but it comes out as 17meg to big to email.

There is either Dropbox or Youtube?
Maybe others too?

Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Fri Oct 03, 2014 11:54 pm

Ran into a brick wall
Brickwall.jpg
Brickwall.jpg (6.16 KiB) Viewed 7073 times


I was trying to load the PIC 16F1937 with Rev 4.

I tried it two ways
1. No +5 from power supply ---- No luck

2. Applied + 5 to rails ---- No Luck.

Here is the error message form Flowcode

Here is the Breadboard

Only thing I can think of is the ICSPDAT and ICSPCLK are connected via Jumpers and maybe getting interference ??

I did check the connects with a meter just to ensure they were correct


John
Attachments
PIC Unable to Transfer.jpg
PIC Unable to Transfer.jpg (35.52 KiB) Viewed 7073 times
PICKIT 2 Access.jpg
PICKIT 2 Access.jpg (49.43 KiB) Viewed 7073 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8826
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2561 times
Been thanked: 3721 times
Contact:

Re: Like to read Port B then send to Port D

Postby medelec35 » Sat Oct 04, 2014 11:48 am

Hi John,
I have just placed a 16F1937 on a plug-in Prototype board.
Connected last two pins of header directly to pins 39 and 40.
connected a 10k resistor between VPP of programmer and VPP of 16F1937.
With no power connected, Programmed board and got:
compile message 16F1937.png
compile message 16F1937.png (69.91 KiB) Viewed 7063 times

With power connected I got the same error as you which is:

Code: Select all

Address   Good     Bad
000000    002BF1   000000

Return code = 34


So you could try removing power as that allows successful programming every single time.

I will see if I can investigate.

Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Sat Oct 04, 2014 5:09 pm

Hi Martin,

I tried it without Power because this is how I did the 16F1827. I was never successful on the "In Circuit" programming with the 16F1827.

I will remove all the PortB and Port D wiring and see if this what is causing the error. I was hoping to do the in circuit so I could load code without having to remove it from the PCB to a breadboard.

I see other blogs that they make it possible.

I will see what happens and add 1 lead at a time to Port B and Port D and see what happens

Glad at this point I haven't send in the PCB to be made.

Off to investigate also

John

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Sat Oct 04, 2014 5:37 pm

Martin your wizard hat was on this morning and you got it to work with no power.

I stripped of all the leads and only had the programming.

I will add 1 lead at a time and see maybe I had one of the Port pins wrong.

More later.

Fun in sun....opps rain outside this morning....Sun this afternoon and high of 21 on Sunday.

John
Attachments
Worked.jpg
Worked.jpg (9.11 KiB) Viewed 7056 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8826
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2561 times
Been thanked: 3721 times
Contact:

Re: Like to read Port B then send to Port D

Postby medelec35 » Sat Oct 04, 2014 7:12 pm

The only issue would be if something else is connected to RB6 or RB7, if not then only reason for non programming is if the 5V supplied by programmer is being pulled down for some reason?
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Sat Oct 04, 2014 7:14 pm

I just replaced the PORT B and it loaded.

Just going to place the Port D.

More soon

John

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Sat Oct 04, 2014 8:18 pm

Corrected on next post
Last edited by JLeith on Sat Oct 04, 2014 8:38 pm, edited 2 times in total.

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Sat Oct 04, 2014 8:26 pm

Maybe I need to wait to test when the LCD arrives so I can see what action is happening.

John

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Sat Oct 04, 2014 8:36 pm

Had the RED led on the wrong port

Corrected

Still won't trigger C7 or D0.

Set the chip timing to 1000 to slow it down maybe I was missing the Port D.

No action at 1000
Attachments
PIC test.jpg
PIC test.jpg (13.65 KiB) Viewed 7047 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8826
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2561 times
Been thanked: 3721 times
Contact:

Re: Like to read Port B then send to Port D

Postby medelec35 » Sat Oct 04, 2014 10:01 pm

Hi John,
Here is what you will need to do to get things running on hardware.
1) It will probably be best to set internal osc at 32MHz (currently the osc is set to external).
To change osc to internal and run at 32MHz you will need to go into the configuration settings and change Oscillator to INTOSC Oscillator, IO function on RA7 etc
Then change PLL enable Bit to Enabled.
Enabling PLL is a x4 multiplier on this chip (Phase locked Loop) so instead of running at 8MHz osc is running at 8 x 4 = 32MHz

2) Change clock speed in the general options tab to 32000000.
The clock speed in general options is just for timing of delays or components that relay on delays. E.g LCD, software I2C, Rs232 etc

3) At the very top of main (before start of any loops) add a c code block with

Code: Select all

osccon=0x70;

The osccon=0x70; sets internal osc of hardware to 8MHz

4) Change MCLR pin function in configuration settings from Enabled to Disabled.
5) You will require to enable weak pullups on port B.
You cant leave an input floating (nothing connected when switch is open circuit)
Luckily port A and port B both have internal weak pull-ups.
So to set weak pull-ups you first need to enable weak pull-ups by adding to the c code block

Code: Select all

clear_bit(option_reg,7);

Now each individual portB pin can have a weak pull-up enable or disable by

Code: Select all

wpub=0bxxxxxxxx;

to enable pull-up x=1
to disable pull-up x=0
So if you use wpub=0b00011111;
Weak pull-ups are only enabled on port B0 to B4
If all of portB weak pull-ups are required then you can use:

Code: Select all

wpub=0b11111111;

or

Code: Select all

wpub=255;

or

Code: Select all

wpub=0xFF;


So now your c code block should have:

Code: Select all

osccon=0x70;
clear_bit(option_reg,7);
wpub=0b11111111;
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Sun Oct 05, 2014 7:36 pm

Wonderful work Martin

I would never would of know these options.

I have made the changes.
1. Chip

2. C Code settings

3. Port D Trigger all when only 1 B - 0 selected

Martin if I set Port B to weak pick up don't I require say a 10K battery supply so Port B doesn't get noise and trigger ?

4. Port B with pull up. --- Only allowed 3 images post on next message
Attachments
Port D all.jpg
Port D all.jpg (19.49 KiB) Viewed 7033 times
C code_A.jpg
2. C Code Settings
C code_A.jpg (22.62 KiB) Viewed 7033 times
Chip Option.jpg
1. Chip Option
Chip Option.jpg (39.56 KiB) Viewed 7033 times

User avatar
JLeith
Posts: 521
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 143 times
Been thanked: 26 times
Contact:

Re: Like to read Port B then send to Port D

Postby JLeith » Sun Oct 05, 2014 7:40 pm

Martin here is part 2

Would this image help stop the other Port B to also trigger

1. Pull up in RED

I have also added the Flowcode version 4.
Attachments
Segment control to Servo v4.fcf
(43.67 KiB) Downloaded 49 times
PIC A Test.jpg
PIC A Test.jpg (15.21 KiB) Viewed 7032 times