PORT B sending sequence

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

PORT B sending sequence

Postby JLeith » Thu Nov 22, 2012 4:07 am

Hi everyone,

I need a little guidance on how to address sending out bits on Port B to control 3 functions with out turning off actions that were in the lower Port B settings.

I really don't want to have to write variables for 8 Banks and 2 states and 8 ( A- G ) segments. ( 128 Variables )

I have put a small PDF to help layout my mystery. ( Sequence of events PDF )

i have also uploaded a sample of the patterns to change the Vans from Ball 1 to Ball 3. ( Sequence Flow JPG )

I hope there is a way.

John
Attachments
Segment Flow.jpg
Segment Flow.jpg (121.14 KiB) Viewed 4597 times
Sequence of events.pdf
(223.67 KiB) Downloaded 137 times

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

Re: PORT B sending sequence

Postby medelec35 » Thu Nov 22, 2012 8:39 am

JLeith wrote:Hi everyone,

I need a little guidance on how to address sending out bits on Port B to control 3 functions with out turning off actions that were in the lower Port B settings.


Hi John,
One way is to use masking techniques.

Basically you AND with a value if you want to clear bits and not affect others

You OR with a value if you want to set bits and not affect others.

Take a look at this:
http://www.matrixmultimedia.com/article.php?a=366

and

http://extremeelectronics.co.in/avr-tut ... velopment/

Even though last url shows AVR, same will apply to pics.

I would help more, but have to go to work now.

If your still stuck, will post flowchart later.

Martin
These users thanked the author medelec35 for the post:
JLeith (Thu Nov 22, 2012 8:43 am)
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: PORT B sending sequence

Postby JLeith » Thu Nov 22, 2012 9:06 am

Hi Martin,

i have read the info and I must say it looks a bit deep to grasp. Yes I will need a little show an tell to see if this is the task I will need.

Add and Or I don't know where to start when I need to send the flow to control the Segments.

The trick is Address only the Segment because the A - G leads are common to all the Segments.

Once you have the Segment Powered up by supplying 12 volts to the Anode more or less.

Step 2 Send the ON or OFF the vans have relays to flip Dark for OFF and Yellow for ON.

Step 3 Is send the A - G segments you need to address.

There is a RC Timer set on Port A Bit 4 to control the 250 ms on state to Segment Power so as not to cook the relays.

You are off to work and I'm off to sleep 12:07 PM PST.

John

I have uploaded the Pic Side diagram to help a little.
Attachments
IC8 PIC.jpg
IC8 PIC.jpg (39.24 KiB) Viewed 4583 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: PORT B sending sequence

Postby JLeith » Thu Nov 22, 2012 9:08 am

Forgot to upload the Flowcode.

Here is
Attachments
Direction Flow with new switch.fcf
(133.96 KiB) Downloaded 100 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: PORT B sending sequence

Postby JLeith » Thu Nov 22, 2012 9:03 pm

Martin I have done some more testing and placed in a PDF

I need a method to control the LED's to show me the action I tried Delays but they led's turn off once the display is stepped off.

I tried to see how I can simulate the LED for the ( A ) vans to wait for the Segment power.

In the design there is a RC time connected to Port A pin 4 that I have to add some code into the flow but If I cant see the LED's staying on during simulation is tough.

I set my 'Green" led to simulate the Timer. I don't know how to simulate the Port A to stay active for 250 ms to allow the Van's to change.

I uploaded the Flowcode. I modified the OUT sequence for Out = 1. But I don't really see it working.

John
Attachments
Direction Flow with new switch.fcf
Flow to simulate the Port B sequence
(134.54 KiB) Downloaded 111 times
Digit Flow for ElectroMechanical digits.pdf
Segment Trial
(177.27 KiB) Downloaded 164 times

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

Re: PORT B sending sequence

Postby medelec35 » Thu Nov 22, 2012 11:37 pm

Hi, just looked at your Circuit and Flowchart.

With the circuit you have got MCLR shorted to GND. This will just keep the microcontroller permanently in reset condition, so your program

will never run.

Within your flowchart you have got

Code: Select all

 {
PORTB = 1
TRISB = 1
}

Important to remember: registers must be in lower case, bit names in uppercase.
Also a semicolon is required at the end.

So its:
portb = 1;
trisb = 1;

With the above statement, all that will do is make bit0 of portB into an input.
To make the whole of portb into an input u can either use an input icon or used:
trisb = 255;

You wond need the portb statmet as that wont do anything.

Another thing is you have:
Ball = Ball
The compiler will optimize that out, so it's not used.
Reason is if ball = 5
then you have got 5 = 5
So the variable is not wort having since it's value does not change.

Not had much time tonight, loads to do, so will take another look at your flowcode when I ge the chance.


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: PORT B sending sequence

Postby JLeith » Fri Nov 23, 2012 3:03 am

Thank you Martin,

Yes I follow your steps on the ( Port ) listings I have a note it has to be in lower case. I have had to do a lot of twisting to see how I can make it work that I have left some statements messed up and catch them as I go.

On the MCLR might not be clear on the drawing but it actually is connected thru a diode and resistor to + 5. it also runs to the Data In Jack ( Jumps over the Ground. Not to clear in the drawing.

I really want to thank you for your help in debugging the process of design the process in Flowcode.

I have cleaned up some routines and will post a new version before the night is out.

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: PORT B sending sequence

Postby JLeith » Fri Nov 23, 2012 5:55 am

Hi Martin,
Well I think I have exhausted all the process I can think of. Reading is getting a bit blinding and no new adventures.

I thought I would try controlling the Push buttons as INPUT Port B and then switch the display to OUTPUT Port B. Maybe its inherent how the buttons and Leds work in Flowcode.

I think the C:code will work I read it in one of my books in the early testing of the "Led Projects"
{
bsf 03h,5;
bsf OPTION,7;
movlw ob0000000; //set PortB Output
movwf trisb;
bcf 03h,5;
}
Reverse B bits for input setting.

I captured the action when I press the Button with the vision that the LED wold not fire they did. I was using Ball 1 to se if the code would work. Press the Button and the B0 Led lights up ?

I named the Flowcode project 'Project with C Code" just so I can keep track of the process.

In the past message you were asking about the ( Ball = Ball ) this is it the Switch detection so that when the Ball 1 returns and the Button is press it now has 'Ball 1" as it enters the Ball display that takes Ball 1 + 1 and now display Ball 2.

John
Attachments
Project with C code.fcf
(131.75 KiB) Downloaded 90 times
C code.jpg
C code.jpg (92.77 KiB) Viewed 4552 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: PORT B sending sequence

Postby JLeith » Sat Nov 24, 2012 4:26 am

I believe I have worked out the issues with running the project as fast as possible and respond to my inputs. I have added the small leds to my panel so I can see when the action happens. The Clear Ball & Strike works and also the Clear Board.

I am no closer
Sad2.jpg
Sad2.jpg (2.85 KiB) Viewed 4537 times
to working out how to make the Buttons ( Port B ) as INPUT and then when a action is requested switch to OUTPUT ( Port B ). I tried to use "C" coding but it was like Flowcode jumped right over the code.

Also how to lock the Port B led's to an on state while it is sending out the Port B output display. It looks like once the Led setting is activate the Led Lights, then as soon as the action steps past the led's turn off.

Even at a speed ( 10 ) I cant keep them on.

I have uploaded the fresh Flowcode called : Flowcode Scoreboard Nov 23.

John
Attachments
Flowcode Scoreboard Nov 23.fcf
Latest version 63
(134.74 KiB) Downloaded 102 times

kersing
Valued Contributor
Valued Contributor
Posts: 1930
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 567 times
Been thanked: 1078 times
Contact:

Re: PORT B sending sequence

Postby kersing » Sat Nov 24, 2012 1:40 pm

John,

You are aware flowcode will not simulate C code? C code will only work on hardware (or simulators reading HEX files like Real PIC simulator)

Regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: PORT B sending sequence

Postby Enamul » Sat Nov 24, 2012 6:59 pm

Hi John,

Jac is absolutely right. You can download and use full version of Real PIC Simulator which is free for one month. Here is some tutorials of how to use the software..
viewtopic.php?f=7&t=11092&p=38288&hilit=Real+PIC+simulator#p38288
Enamul
University of Nottingham
enamul4mm@gmail.com

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: PORT B sending sequence

Postby JLeith » Mon Nov 26, 2012 1:08 am

Thank you Jac

I was think I was going crazy trying to get something to happen and it would not work as I thought.

Jac do you know how I can then make Flowcode respond by making the Port B ports as Logic Low for Button action and then when it is time to send out the display change the bits to Logic High for sending out the display.

I will ha have a look at the "Real PIC Simulator.

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: PORT B sending sequence

Postby JLeith » Mon Nov 26, 2012 7:47 am

Hello Enamul,

I took a look at the ( http://digitalelectrosoft.com/index ) and I sent them an email on the matter that maybe my PIC16F1826 is not supported. From the literature that you sent me it looks like it is what I will nee to finish my design with the addition of some C code to help handle the Port B function and the sending sequence.

Only info I did find is this:
Note
This is a limited functionality demo version. You cannot save projects, save to ASM file the disassembled program. The trial period is 30 days.


I have asked them to email them to see if my issues with Flowcode can be answered.

Enamul why won`t flowcode indicate that the C code would not be followed when you can add code and no indications.

Enamul or Jac have you used the `Real PIC Simulator ?

John

kersing
Valued Contributor
Valued Contributor
Posts: 1930
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 567 times
Been thanked: 1078 times
Contact:

Re: PORT B sending sequence

Postby kersing » Mon Nov 26, 2012 9:40 pm

JLeith wrote:Jac do you know how I can then make Flowcode respond by making the Port B ports as Logic Low for Button action and then when it is time to send out the display change the bits to Logic High for sending out the display.


If you use an INPUT (I) icon to read Flowcode will switch the port to Input. When you use the OUTPUT (O) icon Flowcode will switch the port to output. You do not need to add C code for this.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

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: PORT B sending sequence

Postby JLeith » Mon Nov 26, 2012 9:58 pm

kersing wrote:
JLeith wrote:Jac do you know how I can then make Flowcode respond by making the Port B ports as Logic Low for Button action and then when it is time to send out the display change the bits to Logic High for sending out the display.


If you use an INPUT (I) icon to read Flowcode will switch the port to Input. When you use the OUTPUT (O) icon Flowcode will switch the port to output. You do not need to add C code for this.


Hello Kersing,

I was trying this by setting the TRISB = 0xFF and 0x00 in a C code block but when I ran the simulation I could not see the state ?

Now I just heard back from JonnyW. that yes I should be able to back the C code and Flowcode should follow. I just sent a message to see how to add this to my code.

I have add my current Nov 26 version. I had so many copies I have to date them.

Hope you can help.

John
Attachments
Flowcode Scoreboard Nov 26.fcf
(135.76 KiB) Downloaded 75 times

kersing
Valued Contributor
Valued Contributor
Posts: 1930
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 567 times
Been thanked: 1078 times
Contact:

Re: PORT B sending sequence

Postby kersing » Mon Nov 26, 2012 10:26 pm

JLeith wrote:I was trying this by setting the TRISB = 0xFF and 0x00 in a C code block but when I ran the simulation I could not see the state ?


TRIS sets (parts of) the port to input or output, that in itself is not visible in simulation. And as stated (by Jonny as well) Flowcode takes care of setting the port. If you take a look at the C code for a macro by selecting menu "Macro"/"Show as Source" you will see the C code generated. If you look at the source of the Switch_Input, the macro starts by setting one bit (A4) of port A to output. The input icon sets port B to input...
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

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: PORT B sending sequence

Postby JLeith » Tue Nov 27, 2012 8:07 am

Hello once again Kersing,

You are wonderful in the endless knowledge and I was able to follow the information. I think I fixed up the Port A and also found a error on my Port B setting. This time I set them a Hex values.

I wonder if you could look over the Flowcode and see if I have everything as expected. I uploaded a PDF to help explain the PortA Bit 4 is used as a Resistor / Capacitor timing to supply a 250 msec timer to control how long power is applied to the Mechanical Displays.

When I run it a Full Speed it is hard to see the LED's sending out the output is there a way to slow the Leds to show them in slow motion more or less. Even when the project runs at top speed.

Thank you for the help.

John
Attachments
Port A and B settings PDF.pdf
(157.95 KiB) Downloaded 112 times
Flowcode Scoreboard Nov 26.fcf
(135.93 KiB) Downloaded 77 times