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

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: Like to read Port B then send to Port D

Post by medelec35 »

Sorry John, not had much free time lately.
I will take a look at your posts as son as I can.

Martin
Martin

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: Like to read Port B then send to Port D

Post by medelec35 »

JLeith wrote:Like Port B + Port C 0 = Status 2
So you want C to be checked at the same time as B
or
JLeith wrote:I guess we need a faster determination if a C0 has arrived and after say 100ms C has to be their because if it is for that display the C came in with the B interrupt.
You want to wait at least 100ms to check C after B has been triggered?

C can be checked within microseconds of portB being triggered if you wish?
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: Like to read Port B then send to Port D

Post by JLeith »

Hi Martin,

Thank you for you time

I'm getting lost on the timing without knowing how fast the Port B interrupt and the Port C detect needs. I do know it has 250 msec to detect Port B and check Port C and be ready do do it again.

If a digit display of ( 8 ) there could be eight port B triggers.

Here is how I tested the Control Unit to ensure the sequence was correct. I did find a few missing segments
I had to use 3 breadboards and a 16 relays and now with you kind help moving the actions of the SCR and relays into PIC16F1937
Led on off and control.jpg
Led on off and control.jpg (30.09 KiB) Viewed 14555 times
Here is what I see in the Port B for Digit 1


I hoe this helps I will stop playing around with the timing until I hear back from your thoughts

I did some searching in Flowcode for conversations on Servo control and I was reading something I believe you posted in 2011 a PDF
MX027 - Controlling a Servomotor with timer0
Author: Martin Whitlock
Description: This article describes a method of controlling a model servo motor using a low pin count micro controller running from its internal RC oscillator. A timer interrupt is then used to maintain timing accuracy while allowing the micro controller to perform other tasks.
Is this the process you are think of for the servo action ?
If so I will print it off and do my best to understand the formula

Stand by
John
Attachments
Timing for Port D.jpg
Timing for Port D.jpg (30.71 KiB) Viewed 14555 times

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: Like to read Port B then send to Port D

Post by medelec35 »

Hi John,
Looking at your hardware circuit, you wont need an SCR if you use a double pole relay
You can use the other pole to latch relay.
Sorry for the delay, I'm struggling to find time as my son is stopping with me for the week.

Right I believe I have got a solution, and will post a flowchart as soon as completed.
The idea is:
Use T1CKI (by coincidence also connected to RC0 pin) as another interrupt instead of using C0 and just a normal input.
Action can be taken only if interrupt on both port B and T1CKI is triggered within a set time period say 500ms?
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: Like to read Port B then send to Port D

Post by JLeith »

Hi Martin,
I hope the weather is good for you son's visit. The rain and wind is starting up for our November weather of rain and more rain.

Rain today means I can do more computer work.

For the SCR circuit it is on the dust shelf it was a theory test to confirm if my design for the Control board really did work because I never did get 100% satisfaction on the Elector- Mechanical flip digits. I did find some missing segments in the Inning display when It reached 9 innings and pressed inning again it when to Inning 2.

It was a real mess with 40 breadboard jumpers and my main task was keeping everything straight.

I very happy going down the PIC road it will save a lot of relay's

Solution is music. I have not encountered the term T1CK1 I will do some searching in the mean time so I can follow your design.

Enjoy family time and we will get back when the time is right.

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: Like to read Port B then send to Port D

Post by JLeith »

Hello Martin
Well last week was a total lost.
Crash.jpg
Crash.jpg (23.41 KiB) Viewed 14530 times
My hard drive crashed and quit. We had a power outage and it came back on but crashed again in a minute. I think my PC restarted and was stopped in the middle and that was the end of all end.

So I have a fresh new laptop now a little different then a desk top tower.

All my Flowcode and all my mail is gone. I have sent a message to Matrix to see if they can find my account and if I can get Flowcode 5 with PIC back.

I have downloaded Version 6C of our design for the servo / Port D output.

I will have to wait till I hear back from Matrix before I can get back to design world. I have been trying to build the box for 1 segment servo drive while I wait.

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: Like to read Port B then send to Port D

Post by JLeith »

HI Martin
The LCD 2x16 display have just arrived.
I will be adding pins to the display so I can plug it into a bread board

I do plan to add a port on the display so I can connect the display externally and when a display acts up I can then connect the display to help what is going on.
It is a little easier I think to add the LCD over RS232 access and need to have a laptop.

I have not heard back from Matric maybe I should move to Flowcode 6 and tap into some Christmas funds.

Now that I have lost my notes Martin can you refresh me on what I would need again for Flowcode 6 and the module for multi servo control ?

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: Like to read Port B then send to Port D

Post by medelec35 »

Hi John,
Sorry I have missed this post.
JLeith wrote:Now that I have lost my notes Martin can you refresh me on what I would need again for Flowcode 6 and the module for multi servo control ?
You will require the professional pack and the PIC chip pack.

I have updated the V5 version flowchart to include servos.

Don't forget you can download a trial version with all features/components unlocked so in effect you can use the V6 professional version of flowcode for 30days for free!
I will require some details on how and when you want each servo to operate.
are they just flipped from 0 - 90 back to 0 each time the corresponding port B is detected and now RA4 (not RC0 since T0CKI is much more reliable than T1CKI for some reason)

Perhaps as a reminder you can post step by step signals in/out expected.
Then I can check hardware is following your outlined steps.

Martin
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: Like to read Port B then send to Port D

Post by JLeith »

Hi Martin,

Yes I did see the 30 day trial and I suspect I will take a look at this. I hope to save enough by the 1st of February. Hope it works out.

The action for the servo will be based on 1 PIC as a "ON" going from 0 - 90 responding to the Port B. Then PIC 2 as a "Off" changing the Servo from 90 - 0.

There is a set of "ON" Port B and a set of "OFF" Port B.

In a true world there would be no Port B state having the Servo go 90-0 and 0-90 in the same state of time.

Does this make sense ?

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: Like to read Port B then send to Port D

Post by medelec35 »

Hi John,
JLeith wrote:Yes I did see the 30 day trial and I suspect I will take a look at this. I hope to save enough by the 1st of February. Hope it works out.
Now would be the ideal time then since when it comes to 1st of February you would have been tying V6 for nearly a month so you will have a good idea it you believe its worth getting or not.
JLeith wrote:Does this make sense ?
Not to me, sorry.

All I know is you want action taken if there is a falling edge on a pin on port B & falling edge seen on A4 (changed from C0)
Can you post something like:

RB0 high to low then A4 high to low then servo 0 to 90 deg
RB4 high then A4 high to low servo 90 to 0 deg etc.

Require action steps if possible please.

Or just a timing diagram.
Whichever is your preference.

Martin
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: Like to read Port B then send to Port D

Post by JLeith »

Hi Martin,

I will put something together and post.

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: Like to read Port B then send to Port D

Post by JLeith »

Hi Martin
I hope I have this correct. I lost all my drawings on the PC crash

In the info I think it would read.

RB0 high to low and A4 Low to High then the servo 0 - 90 deg. ( ON State )
2 pic RB0 high to low and A4 Low to High then the servo 90 - 0 deg ( Off State )

The Port D connection to the servo will only receive a ON state and then in the sequence for digits it will receive a Off State.

At no time will a port d be sending out a ON and OFF at the same time.

The A4 is common for PIC 1 & Pic 2
RB 0 - 7 is separate for PIC 1 & Pic 2. Each Port B is either a ON Action or OFF action.

The state for Port A and Port B is from a open state to either a GRD for Port B and Port A4 is open to + 5

Might I need a reference state at the Port B to as resistor with + 5 to detect the Ground state ? and the Same for A4 to be a gound state so it can detect the + 5.

I guess I can send a + 5 on the Port B if this would make it easier to work.

Before in the old mechanical state the Ground on Port B related to the + 5 on A4 to operate. Now they are separate detection states on the PIC.

John

When you build the hex there will be PIC 1 as a ON state and PIC 2 hex will be off state.

I hope I have the info correct for you.

Here is a picture
Attachments
Pic to Servo.jpg
(167.62 KiB) Downloaded 4240 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: Like to read Port B then send to Port D

Post by JLeith »

Hi Martin
I have added a timing diagram for the servo action I hope helps.

Drawing 1 is the action for digit 1
Drawing 2 is the action from 1 to digit 2

John
Attachments
Digit 1
Digit 1
Digit Time Line 1.jpg (74.32 KiB) Viewed 14374 times
Digit 2
Digit 2
Digit Time Digit 2.jpg (125.84 KiB) Viewed 14374 times

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: Like to read Port B then send to Port D

Post by medelec35 »

JLeith wrote:RB0 high to low and A4 Low to High then the servo 0 - 90 deg. ( ON State )
2 pic RB0 high to low and A4 Low to High then the servo 90 - 0 deg ( Off State )
This would not be easy to do even with a diode connected to each output.
Reason is you have two separate low resistance pins connected together and if one changes, its forcing the other to change.
This will probably cause damage to microcontroller.
If you used a diode to separate o/p's then if both chips decide to send a servo signal at the same time, then the pulse width going into the servo would be wrong.
I think you will need to revisit the hardware design before we can continue with software.
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: Like to read Port B then send to Port D

Post by JLeith »

I never thought it would be a issue on the Servo side

There would be only 1 signal at a given time either a ON state 0-90 or a OFF state 90-0.

If RA4) is active on both PIC but there is only PORT B active on only 1 PIC then only the PIC with Active state Port B will be sending the 0-90 or 90-0.

Both PIC will see a RA4 but only 1 PIC will have the Low State on the Port B to relate to which Port D servo flips.

So is the issue that the signal PWM signal send out on say PIC 1 will cause a issue with the PORTD on the 2nd PIC ?

I don't believe we have had a clean state test when a RA4 is set High and the PORTB is set LOW that we get a STATE out of PORTD related to the PORT B state. ?

It works in Flowcode but has not worked on the work bench.

If you can set up a single action for 1 pic to send the 0-90 state. I can wire to servo to simulate digit 1 where PORT B 2 & 3 would relate to Port D PWM 2 & 3.

If you can send me a Hex file for sending the 0 -90 to display digit 1.

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: Like to read Port B then send to Port D

Post by medelec35 »

Hi John,
Try the attached hex file.
LCD is connected to portC as before.
Weak pull-ups on port B

Each time portb 0 is pulled down then released Servos connected to port D2 and port D3
will change from 0 to 90deg, then back to 0 deg again

Martin
Attachments
Servo test1.hex
(11.41 KiB) Downloaded 269 times
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: Like to read Port B then send to Port D

Post by JLeith »

Thank you Martin

I will down load and see what happens.

If you send me the Flowcode version can I still see the flow with version 5 just won't be able to use flowcode to load the PIC ?

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: Like to read Port B then send to Port D

Post by medelec35 »

JLeith wrote:If you send me the Flowcode version can I still see the flow with version 5 just won't be able to use flowcode to load the PIC ?
Attached Flowchart
That is true, you would not be able to compile to hex/chip

Martin
Attachments
Servo test1.fcf
(58.2 KiB) Downloaded 266 times
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: Like to read Port B then send to Port D

Post by JLeith »

Hi Martin
Not sure but nothing happens

I have basic drawing below

How should I test that everything is working correctly ?

I placed a led on the RA4 to ensure I was seeing a high. And it flashed when Ball 1 selected

In the message you said something about weak pull ups on Port B now is this in the hex file ?

Port B will be going LOW when it is receiving the action. So the action would be Pull Downs ??

Now I have not put the LCD in the project. Should I do this to see what might be happening ?

John
Attachments
Servo 1 Test.jpg
Servo 1 Test.jpg (114.02 KiB) Viewed 14292 times

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: Like to read Port B then send to Port D

Post by medelec35 »

Hi John,
Since you asked for a test file to control servos connected to D2 and D3, I modified flowchart to suit.

To make it work I posted some instructions:
medelec35 wrote:Each time portb 0 is pulled down then released Servos connected to port D2 and port D3
will change from 0 to 90deg, then back to 0 deg again
So all you have is one switch connected to portB0

Nothng is yet required for A

If switch pulls down portb0 then releases it, servo should go from 0 to 90deg
If switch pulls down portb0 then releases it, servo should go from 90 to 0deg
etc
JLeith wrote:Should I do this to see what might be happening ?
You can run the flowchart simulation and it will show what the LCD should display.
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: Like to read Port B then send to Port D

Post by JLeith »

Thank you,

I did see them working in the Flowcode file.

I'm working on the LCD display. Not working but I did find a thread from Ben on the wiring for the LCD. I think I need the contrast 5K pot

I was thinking more on the action of the servo when it sees a 2nd low it switches back. Maybe I can rewrite the sequence on the control pic to simulate that action.

More info when I have the LCD working.

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: Like to read Port B then send to Port D

Post by JLeith »

Hi Martin
I was able to get the servo to work.

Still having problems getting the LCD to work ?

The action is on the release of the ground.

When I use a push Button the servo works. But when I use the Scoreboard controller it is a lot faster and the servo does not respond. I even placed the Scoreboard ground through a relay and then supply the Ground from the PIC and still could not get the servo to react.

Thoughts on the PortB 0 timing. I can see the low state from the Scoreboard controller and the Push button. The Push button works but the Scoreboard won't.

I'm going to look more into what is happening to the LCD.

Is there a way to test the LCD outside the PIC ?

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: Like to read Port B then send to Port D

Post by JLeith »

LCD display wiring

And the Port B wiring

John
Attachments
Servo 1 Test with LCD.jpg
(128.97 KiB) Downloaded 4121 times

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: Like to read Port B then send to Port D

Post by medelec35 »

Hi John. Im away for the night so very limited to what I can post as just go a mobile. The lcd is not wired correctly. The data connections go to lcd D4 to D7. Dont forget I only posted a simple servo test. All other functions are disabled. Since servo is working I will post a better version when I get home.
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: Like to read Port B then send to Port D

Post by JLeith »

Thank you Martin

I did get something to display

Black Squares
Attachments
LCD.jpg
LCD.jpg (73.02 KiB) Viewed 14260 times

Post Reply