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
medelec35
Valued Contributor
Valued Contributor
Posts: 8812
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2558 times
Been thanked: 3712 times
Contact:

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

Postby medelec35 » Sun Oct 05, 2014 8:08 pm

Hi John,
It's getting there.
You have got all bits in wpub set at 0:

Code: Select all

wpub=0b00000000;

What that means is none of the B pins have internal weak pull-up enabled so you must have a pull-up resistor connected to each one.
As a reminder: If all internal weak pull-ups are to be enabled on port B then use

Code: Select all

wpub=0b11111111;

Then the resistor in red won't be required!

If any internal weak pull-ups are not enabled, then if you have a switch that goes from the i/p pin to either +5V or 0V then you MUST have a resistor connected from the i/p pin to 0V or + 5V respectively,
You have not done that with C0 so the i/p pin will be floating.
So randomly the i/p could be read as high or low, depended on surrounding electrical noise.
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 8:24 pm

Martin the Flowcode works 100%

Just not on the Breadboard.
Mystery.jpg
Mystery.jpg (3.09 KiB) Viewed 7397 times


Here is what I have
Bar.jpg
Bar.jpg (6.55 KiB) Viewed 7397 times


I tried the 10K and played with the Wpub with all ( 1 ) and ( 0 ). Still can't get the Breadboard to work as the Flowcode so smooth on the Flowcode.

On the Breadboard all Port D display can't get only ( 1 ) Port D to display like the Flowcode action

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 » Sun Oct 05, 2014 8:34 pm

Flowed your listing ( wpub=0b1111111;)

Still not getting Port D to only send out 1 output.

WPUB.jpg
WPUB.jpg (13.32 KiB) Viewed 7396 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 8:36 pm

Yes PortB could be reading noise.. How would I stop this

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

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

Postby medelec35 » Sun Oct 05, 2014 8:58 pm

I don't know if you realize but all of port B is set to detected on rising edge (pins on chip diagram are in red).
For this to work as intended you will need to change the pins to a grey colour.
To change from rising to falling edge, you will need to double click on the interrupt, then select properties.
Click on the down arrow next to 'Select Pin(s)'
Finally keep selecting a pin until the colour changes to grey.

You will need to measure the voltage on C0 and B0 without switch being pressed.
The voltage must be grater than 2V
When switch is pressed voltage must drop to less than 0.8V
Under no circumstances voltage should be between 0.8V and 2V

If that is ok then what I will do is before start of Main loop add an addition loop with say a count of 5.
Set port D high : Delay 500ms portD low: delay 500ms.
After the loop just add port D = 0

Then when power is first applied the whole of port D will flash at 1Hz for a few times then the main program will start.

I can't see anything wrong with your configuration settings.
These users thanked the author medelec35 for the post:
JLeith (Sun Oct 05, 2014 10:26 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 » Sun Oct 05, 2014 9:33 pm

With Port D flashing won't that cause a problem when we go to bit bash the adding in the Servo action ?

I will get out my rust bucket oscilloscope and do some grey area testing.

I have to run out and cut the front grass so it will be looking clean for Halloween decorating in a week or so,

John

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

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

Postby medelec35 » Sun Oct 05, 2014 9:35 pm

JLeith wrote:With Port D flashing won't that cause a problem when we go to bit bash the adding in the Servo action ?

It was only meant to be temp until you get the switch action working and port D lighting up correctly. when that works the loop used for testing D can be disabled.
These users thanked the author medelec35 for the post:
JLeith (Sun Oct 05, 2014 10:26 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 » Sun Oct 05, 2014 10:25 pm

Hi Martin,

Thank you for spending time with my project.

Yes I did realize that Port B was a interrupt I was not expecting to see all the Port D activate when say b0 was selected.

The Flowcode action was 100% action but I don't know what Flowcode does to maintain the action so clean.

I will play with the Ports and when we have time to advance to Servo Bit bashing I will get my pen and paper ready to learn everything I can.

it will be a while for me to save the $260 wrong time of the season.

I did hear back form Matrix and yes it turns out I would need the PRO + Chip pack for $259.50 or ( 145 GBP)

David form Flowcode 5 and Flowcode 6 and all I really need is the PIC and Servo units is:
403 % price increase ( 52 BPB to 260 BPB )

I don’t have any ambition to be a Designer or Engineer just a hobbyist at 60yrs trying to keep the mind active. I haven’t even looked at the Ardino world.

David if the Flowcode 6 is as you indicate at 259.50 for me to work with Servo’s then I guess I will have to stay with Version 5 and work with LED and LCD displays.

On a pension it is not possible to purchase a hobby program for 259.50 ( 400%) in 1 yr.

I will say I really enjoy Flowcode it has made the program 1000% easier then learning C++ programming I have tried and understand the C++ but I don’t know if I could write a workable program.

David I don’t know if I’m the only person that is having to stay with Flowcode 5 with Matrix vision to focus on the Engineers and development world the hobbyist are forgotten.

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 » Mon Oct 06, 2014 1:07 am

Hi Martin,

Well I did some checking and at rest
C0 = 4V
B0= 4V

B0 pressed = .2v

I added the loop 5 as you suggested and I only get D0 on when I say all PORT D = 1. Flowcode acts like Breadboard.

D0 flashes 5 times and then Flowcode follows Port B buttons..... But the breadboard does not activate Port D when Port B is pressed.

Odd now C7 does not come on ?

I labeled the flow as V5. Attached.


John

V5 at least not all PORT D glows when a single Port B comes in.
The Breadboard does not follow

Martin back when I was having problems with programming did I get the impression you had a 16F1937 ?

If so could you breadboard V5 with say D 0 , 1 with B0 and C0

The interrupt is great in Flowcode so why will it not work on the Breadboard ?
Attachments
Sad25.jpg
Sad25.jpg (4.11 KiB) Viewed 7390 times
Segment control to Servo v5.fcf
Version 5
(44.4 KiB) Downloaded 101 times

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

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

Postby medelec35 » Mon Oct 06, 2014 7:36 am

Hi John
No problem,
I can use my 16F1937 on bread board and get it all working for you.

One issue is that i'm use to active high, but your'e using active low so I have corrected that.
I have changed port B IOC from active high to active low as explained in the above post.
I have also changed the max wait time from 500ms to 2 seconds just to allow a bit more time when manually pressing switch.
It can be changed back when happy with operation.

JLeith wrote: added the loop 5 as you suggested and I only get D0 on when I say all PORT D = 1. Flowcode acts like Breadboard.

When using the Entire port rather then single port:
When output = 1 then only D0 will light.
When output = 2 then only D1 will light.
When output = 3 then only D0 & D1 will light.
When output = 4 then only D2 will light.
When output = 5 then only D0,D1 & D2 will light.
Just add up all values for all the LEDs you want to light:

Code: Select all

 D7     D6    D5    D4    D3   D2   D1   D0
128    64    32    16    8    4    2    1

So if you want to light all LEDS:
1 + 2 + 4 +8 + 16 + 32 + 64 +128 = 255
so all PORT D = 255

Finally moved the c code block to the very top of main sice its only when code block is accessed then hardware is set to run at 32MHz.
From memory,before C code is accessed osc will be euinning at 500KHz and all of port b will be floating so LED will take a long time to light.
Ran out of time now, but if you would like to see if assached chart works better, I will check it out myself on hardware later.

Martin
Attachments
Segment control to Servo v6.fcf
(39.93 KiB) Downloaded 93 times
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 » Mon Oct 06, 2014 7:43 am

Morning Martin

Thank you for Version 6

I was having problems trying to see why Port D was not working like Flowcode.

So I printed off the "C Code" to see if I could follow the flow.

I was not aware you had to use the 1,2,4.... to address the Port D. Thank you.

I do print off all your messages and place them in my learning binder so I can refer to them.

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 » Mon Oct 06, 2014 7:49 am

Just loaded Version 6

I see the Port D start all 7 bits flash 5 times.

C7 works

When I take C0 to +5 and then press my B0.........Nothing on Port D

Tried all Port B ----- Nothing on Port D

John

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

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

Postby medelec35 » Mon Oct 06, 2014 9:09 am

JLeith wrote:When I take C0 to +5 and then press my B0.........Nothing on Port D

Woops sorry, my mistake.
I wrongly changed so its waiting for active low on C0 as well.
Changed it back again.
Attachments
Segment control to Servo v6a.fcf
(39.93 KiB) Downloaded 67 times
These users thanked the author medelec35 for the post:
JLeith (Mon Oct 06, 2014 5:51 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 » Mon Oct 06, 2014 5:50 pm

Martin you are a true master.

Fireworks.jpg
Fireworks.jpg (2.56 KiB) Viewed 7368 times


Version 6A works perfect.

I will add it to the Main control module and if I can find a way to add it to YouTube I will send you the link

Just like flowcode

Do I follow the events
1. Adding the C Code
2. Adding the pre loop

Now to the mystery of activating a servo on port d.


worker.jpg
worker.jpg (5.2 KiB) Viewed 7368 times

Ready to work on the next phase. Now those tools I know how to use. " C Code" is a ruff road at 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 » Tue Oct 07, 2014 12:26 am

I have to match the power systems.

The main control panel runs on 12 volts when it sends out the Port B ( Ground ) and the Port C 0 ( +12 converted down to 4.2v )

Martin have you ever used this design
7805.jpg
7805.jpg (15.33 KiB) Viewed 7359 times


I would get the + 12 from the Main control board and this would then match the Ground returns.

Let me know if this is a good design to get the + 12 down so I can use it on the PIC16F1937. Then I will go and get the LM7805

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 » Tue Oct 07, 2014 12:54 am

More research and I found one that has a stable output and protection

Your thoughts

7805 1AMP.jpg
7805 1AMP.jpg (17.74 KiB) Viewed 7359 times


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 » Tue Oct 07, 2014 2:13 am

Martin in Flowcode it looks like the C 7 led is representing a error when ON that there was a Port B interrupt but no Port C 0 received.

In the Rev 6A the Port D flashes 5 times and then the C7 led comes on and there was no Port B input. That doesn't happen in Flow code ?

John

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

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

Postby medelec35 » Tue Oct 07, 2014 6:06 pm

Hi John,
JLeith wrote:In the Rev 6A the Port D flashes 5 times and then the C7 led comes on and there was no Port B input.

I kept resetting hardware and C7 has not lit at all for me when no port B interrupts have been triggered.

As for the servo there is the best (complex way using C code and CCP/Timer interrupts) or the not so good (much easier, but should work) timer interrupt option.
Which path do u think you would rather go down?
Since now its established that port D is fine and osc timing is fine, now the loop and port D flashing a few times can be disabled.

Re protection:
I personally believe it's a bit over the top, but its your build and you go with your preference.
I have never had an issue when 12V or higher going into a 5V regulator has caused any issue with more than 5V at the regulator output.
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 » Tue Oct 07, 2014 11:55 pm

Hi Martin,

On the C7 led it happens when you press a Port B with no Port C active. This way is great because I will be able to see the LED trigger when it see a Port B and times out on the Port C.

I took sometime to follow the LCD display and added a couple of messages. I was hoping my LCD would be here but it does take a lot longer when they come from China.

I have attached Version 6 C with pre loop removed for Port C

On the Servo I would like to go with the Best seeing I need to ensure the segment flips cleanly.

Martin if you think the Easier one will give us the signal cleanly we could do this one.

Which one would allow adjustments if the Servo is a little off. I have read that there can be a difference in the action from 1 servo to the next. I have done some test with a LM555 primitive but I learned the actions. I didn't find the 2 I tested difference.

The servo I have done a little research on is the HXT900
HXT900.jpg
HXT900.jpg (4.95 KiB) Viewed 7338 times


On the Servo action would it make sense to say set Port D 0 as a "On-State and say Port D 2 as a Off State.
When the time comes I will be building 2 PCB for Servo action
1 for ON state
1 for Off State

Will we be using a Macro to call for sending the Servo Actions ?

The Macro would allow me to copy the On - State servo say as ( Servo - ON) flowcode and the other ( Servo - Off ) flowcode. So I will have 2 Flowcode models so I know which PIC gets what.

John
Attachments
Segment control to Servo v6C.fcf
(44.76 KiB) Downloaded 64 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 » Wed Oct 15, 2014 6:35 am

Hi Martin

Something is in the mud.....

The program has stopped running and I have placed the Port C loop back in I even placed a relay in to collect the Port C segment and send a +5 to Port C 0 and still can't get the Port B signal to be sent to Port D.

I have confirmed the Port B is seeing a GRD state but nothing happens.

Opps something does happen.... Port C 7 signals that it says it sees a Port B request but Port C 0 never arrived. I have a LED on Port C 0 to confirm it has a +5 Volt signal but it fails to register.

My LCD has not arrived so I don't see a 100% picture. It is scheduled to be here tomorrow the 15th.

John

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

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

Postby medelec35 » Wed Oct 15, 2014 7:00 am

Hi John.
Can you post a circuit diagram of your whole set up at the time of it all working then going wrong. Was it working then went wrong all of a sudden or did it stop working after sending a new hex file or after modifying your circuit?
Martin

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

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1128
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 521 times
Contact:

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

Postby Steve001 » Wed Oct 15, 2014 7:44 am

JLeith wrote: More research and I found one that has a stable output and protection

Your thoughts


Not been on here for a few days missed your post the first time have you seen these regulators ? bit more expensive more efficient and less of a risk of overvoltage on a failure also has output protection and filter caps internal to the device

Not a lover of "crowbar circuits"

Steve

http://uk.farnell.com/tracopower/tsrn-1 ... dp/2280247
Success always occurs in private and failure in full view.

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 18, 2014 4:46 am

Hi Martin,

Sorry for the delay I was a little under the weather and couldn't get to the computer.

Felling better.

Well I figured out what was causing the Port B issue. I was picking off the input on the back side of a LED Bar that I was using for confirming the A - G leads. I guess the ground was not not going low enough to read it.

On my very first go I was using a push button to trigger the port B and didn't drive it from the display.

Now I have all the Port B active I'm only seeing 1 Port D active. I'm using a LED bar to read Port D.

Example on Port B it will receive a display every 250 MS
Display 1.jpg
Display 1.jpg (22.93 KiB) Viewed 7277 times


When I send in this case ( Ball 1 )
Steps
1. C0 active send B2
2. C0 active send B3

I only see D3 active

I think we need to look at the timing loop for Version 6C
It looks like it is seeing the step 2 but not activating to step 1
Attachments
Segment control to Servo v6C.fcf
(46.63 KiB) Downloaded 73 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 » Sat Oct 18, 2014 5:35 am

Hi Martin,

Well I was able to get it somewhat working but not every time.

I took the Loop for C detection to 1 from 66

And in the return Main I took out the 500 ms on ( Status = 1)

I can get the D2 + D3 on the first power up.

Martin do we need to change the flow to read C then read B where in fact both will be present if it is for this display.

Opps -- Port B is the trigger

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.

The loop has to be ready for the next servo action in the 250ms that the control board will be sending it.

Martin a few weeks back I sent you the Control board flowcode so you could you the digital scope to read the C and B timing ?

Maybe the control board needs to be a longer delay before sending out the next servo to be activated or deactivated.

Not sure how fast the 7 segment is being sent
Segment breakdown.jpg
Segment breakdown.jpg (7.57 KiB) Viewed 7277 times


Martin we will need your digital scope to help determine how fast the 8 bits are sent so we can detect it for the servo PIC

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 24, 2014 7:52 am

Hello Martin

I have attached a word document to help with the layout

I have tried but hitting the wall a little to hard but I can't get the Port D to respond as I was expecting to see

I don't know if you have had the time to do a scope of the Control Board to see how long the Bit 7 for flip segment ( B or C ) are active

I was thinking if after the Port B interrupt if we read port C0 and determine if it is High then move the result to Port D

Like Port B + Port C 0 = Status 2 Were if we get ( Port B + _______ = Status 1 not active.

John
Attachments
Martin could we look at it a little different.docx
Word document with a few pictures
(65.88 KiB) Downloaded 75 times