URGENT help on PIC16F1827

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
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

URGENT help on PIC16F1827

Post by JLeith »

Hello All,

It has been a while since I had to ask for help on my Scoreboard project.

I hope someone can help me determine a fix for my project.

I have spent 8 months on this project and I 'm happy with the flow in Flowcode I just can not make it work in the real world.

I have $700 of my pension money in my project and I'm now at my end. I have placed everything in the circuit boards and I have not been able to make it work.

I really hope someone can explain why I can't make the inputs work as a INPUT and not activate my outbound actions.

I have included my Flowcode and a sample of my frustration. I think when I receive the +5 as an input this works it appears that when I send out PORTB the 4.7K ground is shunting my output signal.
INPUT to RB0
INPUT to RB0
Input RB0.jpg (17.16 KiB) Viewed 17449 times
My last resort might be to change my PIC to a version that has 3 ports like ( RA ) (RB) (RC) then maybe I could receive the RB0-7 and send out on RC0-7. If this is my only solid action can someone recommend a chip that I could use. I don't know how to determine which family I would use and also get a current chip.

I have till April 28th to make my board work or I will be out $700 dollars and 8 months of work. I can see the actions of the down stream chips but the PIC is still a mystery to me.

John
Attachments
Flowcode Scoreboard April 23.fcf
Flowcode file
(135.72 KiB) Downloaded 360 times

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

Re: URGENT help on PIC16F1827

Post by JLeith »

I have come to realize I can work with the RB 0 - 2 coming into the PIC and also feeding back to the 74HC237 this wont harm anything.

MY mystery is now I don't appear to be entering into my sub routines as I would list them.

If you can run my Scoreboard program you will see when you select the "Ball" you will activate the Macro "BALL" and send out a sequence of events.

THIS is my CRASH zone -------- I don't see the RB0 BITS changing from RB3 to RB 7 should be sending out patterns each time you press the button.

I see the macro run in flowcode but not in real life.

I'm back to the scoreboard to use my scope to see why I don't see the RB 3 - RB 7 actions.

John

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: URGENT help on PIC16F1827

Post by Brendan »

Hello John.

If unsolved, could you please post the schematic of the complete interface between the PIC and decoder chip (including circuitry around the decoder) to properly diagnose what may be a possible hardware-related issue?

Thanks,

Brendan

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Brendan,

Thank you I'm still having issues in the Segment ON / OFF not displaying.

I will post a schematic after dinner tonight. I added relays to the output because the flip segments draw at time 1 - 2 amps to flip them at 250 msec.

John

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Hi Brendan

I hope I was able to put together a schematic that will help explain the flow. When I built the control I made a PIC PCB board and a separate Driver PCB just encase I need to rebuild say the PIC board I would have to buy new chips for the driver.

The Flow code works 100% what I would like to see in the real chip function but it doesn't do it.

I have been able to see the bank Selection so it must be seeing the RB 0 - 7 input and send out RB 0,1,3. I have a relay board sending the + 12 from the L293DN and the ULN2004 the current draw from the FLIP digits pops the ULN2004. The Flip coils are 480 OHM and activate on +12 as a common. The Flip Digits have 2 coils 1 to Flip the Display to ON and one for OFF.

What I don't see happening is the A-G segments ON or OFF ?

I really hope you have a idea what is happening ?

I did mechanical testing by manually sending RB 0 - 1, 2 to the 3 / 8 decoder and get the expected outputs and the same with the 74HC237 for ( A-G) all followed the expected results.

I just don't see why the PIC is not sending the info out.

I think the code is set to Send when needed and Receive when Needed.

I add the A6 in Flowcode to track events in Flowcode.

Time is ticking and I really would appreciate your input.

John
Attachments
Summary of Scoreboard PDF 1.pdf
I had to take the Schematic out of the Word Document PDF
(170.25 KiB) Downloaded 385 times
Scoreboard Schematic April 26 75.jpg
I did get a Smaller Schematic to upload
(166.43 KiB) Downloaded 4901 times

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: URGENT help on PIC16F1827

Post by Brendan »

Hello John.

Apologies for the delayed reply - Too many projects and too few hours in the working week.

I notice from your circuit that diode D1 will scupper things. When you hit the button it will pull down bias from the 1k pull-up but the diode will block pull-low logic at the MCLR pin - effectively rendering the input floating logic at that time. I would advise simply replacing the diode with a 47k resistor which should sufficiently avoid interference to VPP if programming in-circuit. Keep the 1k pull-up to the switch as this will ensure sufficient wetting current for reliable regular operation.

Please let me know your results once the above is resolved.

All the best,

Brendan

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Hi Brendan

Thank you I have modified my circuit with the 47K. I was not doing in-circuit I was not having any success. So I do the programming at my computer and then put the chip in the circuit.

I think in my Ball segment I have the wrong setting for the Segment control. I will fix the code and post a new flowcode.

Brendan do you know of a way I could mock up a circuit that would simulate the actions of the flip on / off and use 7Seg displays ?

I tried but no luck mocking something up.

I couldn't figure how to do the Segment ON and then OFF with 7segment displays ?

Also when I removed the +5 on Common Anode display I lost the 7 Segment display.

Not sure how to make this 7 Segment to simulate my program without having to connect it to the Scoreboard. It is a lot easier using 7 Segment in my work shop des.

I uploaed on how the Flip Display works.
Attachments
Flip Segment flow
Flip Segment flow
Scoreboard Flip Control.jpg (14.67 KiB) Viewed 17336 times

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: URGENT help on PIC16F1827

Post by Brendan »

Hi John.

The trouble with your circuit is the multiplexing of port B as inputs and outputs, as you've already identified.

I believe this can simply be resolved by commoning all Latch Enable pins together (pin 4) of IC1, IC4 and IC5 and returning them to an available port A pin (let's say... RA1). Leave pins 5 and 6 of the latches tied low/high as they are to sustain decoded output logic.

Your flow should then first set the output data on port B and then drive RA1 momentarily low (for at-least a few μs) to clock the latch data into these decoders, returning RA1 high immediately afterwards to prevent switch logic (from the module) from affecting the condition of the latched data when port B I/Os are returned to inputs. R1 to R8 should ensure that any possible status of the switches cannot corrupt data from Port B while outputting logic to the latches.

Your diagram doesn't show sufficient detail of the module circuit or whether you have pull-ups or pull-downs on the module (representing inactive switch logic), but this would be necessary to avoiding floating logic when port B I/Os are returned to inputs. If necessary, you could conveniently apply fairly weak pulls directly to port B, ensuring that they don't significantly divide down the switch logic via R1 thru R8.

I hope this makes sense.

All the best,
Brendan
Last edited by Brendan on Wed May 01, 2013 12:35 am, edited 1 time in total.

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Hi Brendan,

Thank you for the suggestions on the IC 1 - 5

I did have to add a 4R7 K to the RB 1nputs to stable the RB transfer.

Here is a mock up.

Any thoughts on how I could use 7 Segment displays to simulate the Flip controls ?

John
Attachments
RB0 -7 Input.jpg
RB0 -7 Input.jpg (18.97 KiB) Viewed 17328 times

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Hello Brendan,

I made the changes you suggested and I made a small step in the right direction and then fell off the cliff edge.

I have focused on making the "Ball" display work and then maybe I can move on.

I can now see the input from the receiver and I can now see the RB output and send Ball 1 as Segment B and C

Now my NEXT cliff edge is I can't get the PIC to go to Ball 2 and then Ball 3.

In my May 2 Flowcode works like a charm but not so much on the PIC.

I added RA 1, 2 , 3 to the Ball Display so I could use my Scope and see if I was entering into the flow. ----> No action on Ball 2 or 3. The A 2 or 3 would not change.

Can you see what could cause Flowcode to work but not the PIC.

John
Attachments
Flowcode Scoreboard May 2.fcf
Flow code May 2
(138.62 KiB) Downloaded 316 times

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: URGENT help on PIC16F1827

Post by Brendan »

Hi John.

I think I'm running a little blind...

Your circuit shows only A1 thru A4 connected to anything, but your code also writes '0' to A6 at the end of macro 'Ball_Display'. Is this an error?

Also, my suggestion was that A1 were commoned to pin 4 of latches IC1, IC4 and IC5, but the flow in "Ball_Display" writes '1' to A2 and A3 in 'Display 2' and 'Display 3' which are also disconnected in your published circuit. Is this an error or are you enabling the latches independently instead? Nothing wrong with that, but I need to be on the same page to consider the process required.

In summary (assuming IC1, IC4, IC5 pin 4 connected together and coupled to port pin A1, as per my suggestion), the sequence for writing to the latches would be as follows.
NOTE: A1 always starts off at '1' before the write operation (always left that way after the previous write operation).

1. Set latch data on Port B (data for all latches)
2. Drive A1 low for at-least 3us (I'd suggest at-least 10us to be absolutely sure of a solid write)
3. Drive A1 high again to disable writes to all latches.
4. Continue reading the switch inputs and repeat from 1 when another latch update is required.

Don't forget that the Flowcode development environment is a logical environment - not a hardware simulator. Never assume that just because it works in Flowcode simulations it will also work on the hardware.

All the best,
Brendan

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: URGENT help on PIC16F1827

Post by Brendan »

Brendan wrote:Hi John.

I think I'm running a little blind...

Your circuit shows only A1 thru A4 connected to anything, but your code also writes '0' to A6 at the end of macro 'Ball_Display'. Is this an error?

Also, my suggestion was that A1 were commoned to pin 4 of latches IC1, IC4 and IC5, but the flow in "Ball_Display" writes '1' to A2 and A3 in 'Display 2' and 'Display 3' which are also disconnected in your published circuit. Is this an error or are you enabling the latches independently instead? Nothing wrong with that, but I need to be on the same page to consider the process required.

In summary (assuming IC1, IC4, IC5 pin 4 connected together and coupled to port pin A1, as per my suggestion), the sequence for writing to the latches would be as follows.
NOTE: A1 always starts off at '1' before the write operation (always left that way after the previous write operation).

1. Set latch data on Port B (data for all latches)
2. Drive A1 low for at-least 3us (I'd suggest at-least 10us to be absolutely sure of a solid write)
3. Drive A1 high again to disable writes to all latches.
4. Continue reading the switch inputs and repeat from 1 when another latch update is required.

Don't forget that the Flowcode development environment is a logical environment - not a hardware simulator. Never assume that just because it works in Flowcode simulations it should automatically work on the hardware.

All the best,
Brendan

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Sorry for confusion. My mind is sapped trying to get the Scoreboard running.

Let me try and layout my attack.

I left IC1,IC4,IC5 as normal , they appear to be working and I was not wanting to cut leads on the PCB at this moment in panic. When I simulated a PIC by sending the sequence to the IC1 --- IC7 it works like it should and the output relays respond. But not when I ask the nice PIC to do the calculations.

I was using the A1 --- A3 to tell me when the code entered the Ball 1 --- Ball 4 so I could use my Scope to see the PINS change if it did work ----- Odd that A1 was high and I don't see in the C code where it was getting that but also A2 or A3 went high so this led me to think and that is getting hard to follow but no action would mean it did not enter the code.

Not sure the term latch data on Port B ??

Brendan can you modify my Flowcode and post it say as May2A with changes you feel might make it work. Please.

Bomb Shell -- Bang - I was informed back in Oct 2012 when I started this journey that flowcode would develop my PIC to work in the same manner ??

i posted the world of my Project. I though it would be easier to replace parts if I really need to as the project grows. I was hoping to ad Pitch Count Displays but at the rate of even getting 1 Segment to works is a little ways away if at all possible.

John
Attachments
World of Scoreboard.jpg
World of Scoreboard.jpg (83.58 KiB) Viewed 17275 times

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: URGENT help on PIC16F1827

Post by Brendan »

Hi John.

Before we go any further, and considering stated anomalies, can I ask if your PIC is situated adjacent to the 5V regulator and output decoupling capacitor?

I ask this as I see lots of thin wires in your image, but can't tell where your PIC is located in relation to the regulator and decoupling cap. In any case there should be similar supply decoupling local to the PIC (as close as possible to the supply pins) as any supply wire inductance to the PIC can easily destabilise operation from even sub-microsecond transients created by the PIC itself. For example, could it be that actions following RB0 activation (Ball switch) are causing following actions to induce momentary supply transients that are corrupting registers and normal PIC operation - even causing a brown-out reset? As there's only a single decoupling capacitor in the entire circuit, this possibility should be eliminated. The PIC should ideally have it's own dedicated supply and ground connections to the regulator (i.e. nothing else supplied from them), preventing other circuit current from creating supply drop-out at the device.

Please ensure adequate PIC supply decoupling with a 100nF to 1uF ceramic cap directly across the PIC supply pins, and check the 5V rail at the PIC holds up without dips after activating the Ball button.

All the best,
Brendan

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Hi Brendan

No I had to abandon the on board 5 volt it was not working as I hoped I have had to add in a external 5 volt feed.

I have scoped the 5 Volts supply and I don't see any fluctuation that could cause a brown out. I will place a cap across the supply to the PIC.

In the picture the Blue wires are 5 volt to the Receiver to send to the PIC input and 5 volts for the PIC and 5 volts to the Driver IC1 - IC 7

So I should have a separate 5 volt feed to the PIC and a separate 5 for the IC1 - IC7 and the receiver ?

If I was seeing the brown out why would I see the Ball 1 come out and not the Ball 2 - 4 ?

I will do a study on the PIC power in the morning.

John

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: URGENT help on PIC16F1827

Post by medelec35 »

Hi John,
Have you considered using RS232 as a diagnostic tool?
It takes a lot of the guesswork aspect out.
You can use it to send message "Pic Reset"
send values of variables etc.
These values could be captured and analysed.

I did this when using PIC16F1827 and discovered Pic kept resetting every time adc was read.

What I do to save pins is assign TX and RX with the same pin.
To send a variable via RS232 just have a Temp string of say 5 chars.
Then within a macro i have Int to string and send string to RS232 which sends names of variables and their values via RS232.

If you decide you would like to go down that route to see what's happening I can help you.
If not then just before start of main loop, just place something to let you know chp is resetting, eg led flash 5 times etc.
Martin

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Hello Martin it has been a road that I have hit so many pot holes I have lost more tires and sleep and endless worries that I will never get this project working and lost $1400 but I have learned more on the factual chips then any knowledge on the PIC.

Martin I understand the process of RS232 I just don't know how to add this to my Scoreboard design and also how to read the RS232 message back once it has been sent.

Martin you have been a great user in helping me in the past to at least get the PIC working in flowcode

Martin would you have a moment to help me develop the RS232 and see what is going on.

Where do I begin ??

John

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Hi Martin,
I have tried to read more on the RS232 and I believe I could use RA1 and RA2 and send this to a RS232 port and I think I need a Laptop to read the info ?

I do have a laptop to use. Just don't know how to set it up to read the info.

I can take the PCB out and solder in a RS232 interface to plug in the laptop,

Again I will really appreciate you helping me set up this needed step.

I have a May 2 copy of my program up a few post before this.

John

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: URGENT help on PIC16F1827

Post by medelec35 »

Hi John, its not a problem I can take you through the whole process step by step.
The RS232 method I have used has given me a 100% success rate is solving bugs use on several projects.
You must have Flowcode professional since home or free versions do not support RS232 or any other forms of communications.
The only additional hardware required is a cheap USB to UART converter. (unless you have USB built in to your microcontroller that is. E.g 18F4455)
For example I have seen one on RS for £9.28:
http://uk.rs-online.com/web/p/interface ... s/7676200/
(It states its for Raspberry Pi but should work with your target device)

If you don't have an account with RS then similar thing can be bought from or component suppliers or online auction sights.
If you are buying a different one from the one I posted about, then make sure it is 5V as there are two common voltages:
3V3 or 5V
Once you have purchased a USB to UART converter, I can post some sample Flowcharts how I use RS232 as a diagnostic tool.
JLeith wrote:Hi Martin,
I have tried to read more on the RS232 and I believe I could use RA1 and RA2 and send this to a RS232 port and I think I need a Laptop to read the info ?

I do have a laptop to use. Just don't know how to set it up to read the info.
A laptop or PC will suffice.
Once you have purchased a USB to UART converter, I can post some sample Flowcharts how I use RS232 as a diagnostic tool.
Then I can help you set up a freeware comms program on your PC, so you can see the values of ports variables etc.
Martin

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Thank you Martin,

I'm off to the Electronic store to see what I can find.

My version is a Student Version and I can see the RS232 panel
RS232
RS232
RS232 Panel.jpg (24.21 KiB) Viewed 17204 times
So how can I see if it works or do I have to spend more money ?

John

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: URGENT help on PIC16F1827

Post by medelec35 »

JLeith wrote: My version is a Student Version and I can see the RS232 panel
I'm sorry even though you can see the RS232 panel, you won't be able to compile with it :(

But that won't stop us from trying.
If you would still like to purchase 5V uart to usb converter, I can add RS232 to your Flowchart and compile it for you.
once you have the hex, you can programm target.

Then you can test with RS232, and decide if you would like the professional version of Flowcode.
At least you won't' be out of pocket by purchasing student version as you only pay the difference.
So the cash you will have to pay out, it will just as though you only bought professional to start with.
Martin

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: URGENT help on PIC16F1827

Post by Brendan »

Hi John.

Microntrollers in particular should always have a suitably low-impedance supply, so decoupling at/near the chip is a must. The small spikes are not always detectable as the bandwidth of internal latches and registers is often much higher than many scopes. If the PIC is mounted on a circuit board with adjacent power supply, the board will typically offer low-impedance tracking from the regulator to the PIC allowing supply decoupling to be shared. Dedicated local decoupling is however a must with distanced supply wired to the PIC.

With a good supply source the PIC can and should share the same supply as other circuits, but don't daisy-chain from the PIC board in your scenario. Simply return the PIC supply wires separately to the regulator. By this I don't mean to suggest that this is the likely problem, but best practice that can avoid days of fruitless code debugging if it were (and I have seen similar issues myself in the past).

Best wishes for a successful resolution, and you're in good hands with Martin.

All the best,
Brendan

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Hello Brendan,

I ran the +5 to a common point and used a distribution point to the other boards. I also did that for the Grounds.

My thought was if I had to remove a PCB I could disconnect the power and the DB9 connections and remove the PCB.

Thank you

John

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

Re: URGENT help on PIC16F1827

Post by JLeith »

Hell Martin,

Well I did track down a USB to DB9 Converter.

I will then suspect make a DB9 header and connect to the PIC ?

Here is a picture of the device.
USB to RS232.jpg
USB to RS232.jpg (100.83 KiB) Viewed 17185 times
The shop says this will do the job.

John

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: URGENT help on PIC16F1827

Post by medelec35 »

I don't believe that will do the job (I could be wrong though)
The converter you require must be 5V TTL UART compatible. TTL being the key word when your asking in a shop.
The serial converter you're showing is probably for PC serial to usb which are totally incompatible voltages. With that type of voltages you will need extra components ot convert from pc RS232 to TTL compatible.

Since you're not in the uk how about this:
http://www.ebay.com/itm/USB-To-RS232-TT ... 4ac333da8c
?
Martin

Post Reply