Page 1 of 2
Learner PIC
Posted: Fri Jan 30, 2015 1:10 pm
by Jayadev
Hello everybody,
I am Jay, a beginner in embedded programming and I have no idea of any other programming language.I came across this amazing tool flowcode through youtube .
I expect to build some basic circuits and at first and learn.I have good skills in Analogue and linear electronics.
I have some pic micros recently purchased a Pickit2. I have already downloaded some ready to use firmer and made a few simple working e.g A frequency counter and a Inductance meter,But I came across some issues with codes which I am unable to resolve so I thought I should start building codes myself.So I started off by Learning C and "Hello world" but I understood it will take me very long to make it . FLowcode looks very promising and it seems to be virtually working.
As of now I am trying to make a switch with 12f675 which turns on with momentary switch and turns off with next press.But it is is supposed to activaate only when switch is depressed but my code gets active moment switch is pressed and it gets kind confused and it remain in state I can noticed code is running in the simulation.
I hope I am right place to seek help.
Thank you
Re: Learner PIC
Posted: Fri Jan 30, 2015 3:15 pm
by medelec35
Hi Jay,
welcome to the forums and the world of flowcode.
Yes you have posted in the right place for help
I have attached how I personally create a flowchart to toggle an output for a momentary switch.
I would recommend taking a look at the
Learning Centre
I would also suggest following the link that's a part of my signature.
Good luck and most of all, have fun!
Martin
Re: Learner PIC
Posted: Fri Jan 30, 2015 9:36 pm
by Jayadev
Thank you very much martin I am going through the learning centre as of now.Will come back
Regards
Re: Learner PIC
Posted: Fri Jan 30, 2015 10:53 pm
by medelec35
No problem if you get stuck then we can off further help.
One thing you will need to do is change the clock speed to 4MHz (Build, project options), as I left that bit out.
Martin
Re: Learner PIC
Posted: Sat Jan 31, 2015 12:40 pm
by Jayadev
What is cost of Flowcode for beginner like me? I am from India.I did not find merchandise link in matrix website.
It looks like my demo V6 will expire within a few days.Will I still be able to continue using it for learning/programming purpose for my basic projects ?
Re: Learner PIC
Posted: Sat Jan 31, 2015 1:34 pm
by medelec35
Hi Jay,
Jayadev wrote: I am from India.I did not find merchandise link in matrix website.
If you go to the main site:
http://www.matrixtsl.com
Select
About then
Distributors
You will be able to select your nearest country:
Jayadev wrote:It looks like my demo V6 will expire within a few days.Will I still be able to continue using it for learning/programming purpose for my basic projects ?
I believe it resorts to the free version.
The
datasheet shows this:
To me it looks like the free version (after 30 days) does not compile to hex since there will be no chip pack enabled.
I could be wrong of course so someone else may have to answer that one.
Martin
Re: Learner PIC
Posted: Thu Mar 12, 2015 10:13 am
by Jayadev
Hi Medelec,
Thank you for your support.
Yes you are right there is some limitations but I am going through videos and trying to learn.Without having much of programming skills and all by myself I am on a bit of hard road . I will be in touch here.
Re: Learner PIC
Posted: Thu Mar 12, 2015 10:22 am
by Jayadev
medelec35 wrote:Hi Jay,
welcome to the forums and the world of flowcode.
Yes you have posted in the right place for help
I have attached how I personally create a flowchart to toggle an output for a momentary switch.
I would recommend taking a look at the
Learning Centre
I would also suggest following the link that's a part of my signature.
Good luck and most of all, have fun!
Martin
Hi Medelec,This 'file' being my proper learning foundation . I am tweaking and trying many things.e.g PWM driver,LED dimmer,timer etc. I feel great to say I see hopes.
Can you also Demostrate how to add an l eprom or memory so that the Pic remember/read the last state when power is turned back on .I am not sure if this x675 is capable of exernal eprom or maybe if you have a better one please do share and help.
Thanks in Advance.
Re: Learner PIC
Posted: Sat Mar 14, 2015 7:53 pm
by Jayadev
Hi Martin,
I am trying to add another switch ,but somehow it doesn't seems to work for me.I am sure I am missing something .Please help
PFA.
Re: Learner PIC
Posted: Sat Mar 14, 2015 9:08 pm
by medelec35
Hi Jay,
What problem are you having with adding switches?
Can you give more details please.
I went to the Inputs menu, selected switch and add to dashboard panel and switch was placed in the dashboard panel OK:
Do you still require help with EEPROM?
Martin
Re: Learner PIC
Posted: Tue Mar 17, 2015 5:01 pm
by Jayadev
medelec35 wrote:Hi Jay,
What problem are you having with adding switches?
Can you give more details please.
I went to the Inputs menu, selected switch and add to dashboard panel and switch was placed in the dashboard panel OK:
Adding sw.png
Hi Martin,
I have added the switch to panel but I am unable to get the bistable condition for the second switch /led. please see to the attached file in my previous post.
medelec35 wrote:Do you still require help with EEPROM?
Martin
I would be obliged if you could help me with eeprom internal or external.As how it reads and writes every action and remembers after power off/on
As I am a beginner I am finding bit hard to get it.
Re: Learner PIC
Posted: Tue Mar 17, 2015 8:45 pm
by medelec35
Hi Jay,
I have modified Flowchart to work with 3 switches and save output to internal EEPROM
To view the contents of EEPROM select Console from the View menu.
When reading EEPROM you need to not that the default value is always 255
What I do if 255 could be a value I would like to save is when writing to EEPROM say address 0 (1st address) for the fist time is also write a set number to address 1.
Then when power is restored, address 1 is read first, if it is the set number then read address 0 and assign to variable.
If address 1 is not the set number then ignore value of address 0
Things to remember about writing to EEPROM is they have a limited number of guaranteed successful write times (between 100K and 1M for 12F675)
So only write to EEPROM when necessary.
when you do write to EEPROM and remove power, EEPROM should how the correct value for at least 40 years!
Martin
Re: Learner PIC
Posted: Wed Mar 18, 2015 2:47 pm
by medelec35
Modified Flowchart to use 3 bool variables for the 3 outputs.
Still only using a single byte to store individual bool values within EEPROM
Just saves EEPROM space.
Martin
Re: Learner PIC
Posted: Fri Feb 12, 2016 9:23 pm
by Jayadev
medelec35 wrote:Modified Flowchart to use 3 bool variables for the 3 outputs.
Still only using a single byte to store individual bool values within EEPROM
Just saves EEPROM space.
Martin
Hi Medelec,
Due to some unavoidable reasons my study of programming completely halted.
But I am back to it again and I will stick to it henceforth .Apologies if that looks awkward.
I am trying to understand this expression from above file
"Output = Output XOR Switches << 3" (XOR - Exclusive OR <<3 = shift left 3 palces which is same as * 8 )
I do understand what is Xor.
What I dont understand <<3 shifting 3 places to left.What is being shifted to left here. And how does the Program recognizes which switch is being pressed and which output should be toggled correspondingly.
Thanks.
Re: Learner PIC
Posted: Fri Feb 12, 2016 11:03 pm
by medelec35
Hi Jayadev,
Jayadev wrote:I do understand what is Xor.
XOR is eXclusive OR
Which means the output is high only when both inputs are exclusivity different.
The <<3 (shift three places to the left) just shift the bits 3 places to the left because the i/p is the first 3 bits and the output is from bit 4 to bit 7
For example if the output variable is 0 and A1 switch is high then with out the shift you have output = 00000010
now shift 3 places you have output = 00010000 = 16 which will light LED on A4
Reason for XOR is if A1 goes high again and is shifted 3 places to the left you will have
output = 00010000 XOR 00010000
the truth table for XOR is:
Since we are looking at bit 4 they are both 1
so 1 XOR 1 = 0
so bit 4 changes from 1 to 0 turning off LED on A4 so output = 00000000
Again if A1 is high then shifted 3 places to the left is high so you have
00000000 XOR 00010000
then A4 will go from low to high.
The affect of using XOR is to simply toggle a bit every time the switch is high.
Martin
Re: Learner PIC
Posted: Sat Feb 13, 2016 10:06 am
by Jayadev
Hello Medelec,
Thank you quick response.
medelec35 wrote:
The <<3 (shift three places to the left) just shift the bits 3 places to the left because the i/p is the first 3 bits and the output is from bit 4 to bit 7
Does this 1-7 'bit' means pinout for the ports which is not as straight as I think or something more please explain . (attached a picture)
medelec35 wrote: For example if the output variable is 0 and A1 switch is high then with out the shift you have output = 00000010
now shift 3 places you have output = 00010000 = 16 which will light LED on A4
I noticed and understood that Bits are being shifted physically (not added),doesn't that mean we can use integer '16' directly to toggle A4 output (in general),If yes how it would be done.
medelec35 wrote: Reason for XOR is if A1 goes high again and is shifted 3 places to the left you will have
output = 00010000 XOR 00010000,Since we are looking at bit 4 they are both 1,so 1 XOR 1 = 0,
so bit 4 changes from 1 to 0 turning off LED on A4 so output = 00000000
Again if A1 is high then shifted 3 places to the left is high so you have
00000000 XOR 00010000 then A4 will go from low to high.
The affect of using XOR is to simply toggle a bit every time the switch is high.
Martin
This is well explained ,very helpful .However I am having a little trouble to picturise the bit wise operation probably because I am a newbie.I will try this out on a paper and see.
In below pic I see a red star on all of my flowchart boxes. Why are they showing up?
Re: Learner PIC
Posted: Sat Feb 13, 2016 12:20 pm
by medelec35
Hi Jayadev,
No problem.
Jayadev wrote:Does this 1-7 'bit' means pinout for the ports which is not as straight as I think or something more please explain . (attached a picture)
Yes It is the pinout for the port.
The port in this case is 8 bits wide but we are just using bits 0 to 5 (A0 to A5):
Jayadev wrote:doesn't that mean we can use integer '16' directly to toggle A4 output (in general),If yes how it would be done.
That's why you shift bit 1 three places.
If switch on A1 is high = 2.
Then by shifting it three places it is going to be =16
So if port A was already = 16 and you XOR with 16 then that bit will go to 0.
If port A was 0 then after XORing with 16, port A = 16
Jayadev wrote:In below pic I see a red star on all of my flowchart boxes. Why are they showing up?
Red stars just means changes have been made since flowchart was last saved.
So if you save the flowchart all stars will disappear.
As soon you add or edit a component or calculation box, then the star will appear until flowchart is again saved.
As a seperate note.
If you press F8 to single step, Select arrow next to expression, it will allow you to add variables so you can watch what their values are.
This aids in debugging and helps to find out how flowcharts work.
Martin
Re: Learner PIC
Posted: Sun Feb 14, 2016 10:37 am
by Jayadev
Hi Medelec,
Thank you for above explanation.
I am trying to use a rotary encorder in place of the toggle switches so that whichever side the Encoder is rotated that side led glows,but the output from an encoder is bit complex compared to toggle switches.
Also I am unable to rotate the encoder in simulation to see the changes. like the way toggled switches
Re: Learner PIC
Posted: Sun Feb 14, 2016 11:24 am
by medelec35
Only when flowcode simulator is running you can click the red arrows to move in the direction arrows show.
Keep mouse button down for continuous movement.
Re: Learner PIC
Posted: Sun Feb 14, 2016 12:22 pm
by Jayadev
medelec35 wrote:Only when flowcode simulator is running you can click the red arrows to move in the direction arrows show.
Keep mouse button down for continuous movement.
I did that way but it does not move. Is it due to my code is not right?
Re: Learner PIC
Posted: Sun Feb 14, 2016 12:35 pm
by medelec35
If you post your flowchart I will take a look.
Re: Learner PIC
Posted: Sun Feb 14, 2016 1:24 pm
by Jayadev
medelec35 wrote:If you post your flowchart I will take a look.
I just downloaded Quad enc test file "
http://www.matrixtsl.com/wiki/index.php ... General%29"
ANd tried to add the encdoer but it would not move.
Re: Learner PIC
Posted: Sun Feb 14, 2016 1:45 pm
by medelec35
Hi,
you had two encoders added to your flowchart.
One on the system panel and one on the dashboard.
The components won't simulate (rotate on the panel) if enable wasn't added.
This turned out to be the case.
Encoder on the system panel does have enabled component added so that does rotate just fine.
I have removed encoder from the dashboard.
Martin
Re: Learner PIC
Posted: Tue Feb 16, 2016 5:51 pm
by Jayadev
Hi Medelec,
Apologies for being so naive. I am supposed to go through lot of example files before asking questions but being such a newbie I am finding it difficult to move ahead.
I have have a few doubts.
1.As per the flowchart I thought the counter would reset after 255 but it doesnt.it seems to be counting forever.I made it count more than 1049
2.What does LCD_Write > 50 means in the decision box?
3.How do I add some words I think they are called strings. e.g. "No. of Rotation=140++"
4.What is difference between 'i==2' and 'i=2'
5.Fortunately,It seems like I don't have to add any codes for rotaryEncoder (Thanks to Flowcode team,But I will try to learn C as well soonest)
6.What would be my next step to say output the encoder to another port as serial data or pwm?
7.It seems like my logical part of the brain is not sparking up ,Why I am unable to find a quick solution,is it because I am a newbie ,lack of practice or do I have any reference books as learning aid.
Re: Learner PIC
Posted: Tue Feb 16, 2016 8:39 pm
by medelec35
Jayadev wrote:1.As per the flowchart I thought the counter would reset after 255 but it doesnt.it seems to be counting forever.I made it count more than 1049
It depends on what type the variables are designed to.
When you add a new variable:
You can see if you add a byte, when incrementing the variable will go 254,255,0,1 ...
When decrementing the variable will go 2,1,0,255,254....
Since Count variable is an integer then it will count to 32767 then If 1 is added will roll-over to -32768, -32767,-32766 etc.
If you want the count to stop at 255 and go to 0 then you need to change count variable from Integer to Byte.
Or you can add a decision branch
If Count >= 255 then Quad component ResetCounter
The 255 can be any number you like.
Jayadev wrote:2.What does LCD_Write > 50 means in the decision box?
I did not develop that flowchart but it look like its used to refresh LCD when LCD_Write is greater than 50.
Jayadev wrote:3.How do I add some words I think they are called strings. e.g. "No. of Rotation=140++"
There are two ways.
1 add a LCD PrintString component then add "text" within expression box:
2 You add a string variable and at the end of the name palce[] with the size within brackets.
Then within flowchart instead of adding "text" you add the string variable.
Jayadev wrote:4.What is difference between 'i==2' and 'i=2'
With Flowcode you can use either so nothing .
Jayadev wrote:6.What would be my next step to say output the encoder to another port as serial data or pwm?
Plan what you want to do then learn how it's controlled e.g. PWM
To do that look at the
Learning centre as there is a free Flowcode Beginners course & numerous examples.
Also take a look a
Flowcode wiki as there are links to examples.
These links and others can be found on the matrix main site under support.
You can use the variable values generated by the encoder to alter PWM (or whatever you want to do the encoder values)
Jayadev wrote:Why I am unable to find a quick solution,is it because I am a newbie ,lack of practice or do I have any reference books as learning aid.
Answered above.
Also there is an Book by Bert Van Dam see
This link
You will be best doing some research, looking at examples and watching
youtube videos
Hope this helps you.
Martin