Servo Program Settings

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

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Servo Program Settings

Post by JDR04 »

Hi everyone, I've done my program and am happy as to how it simulates.

Before I try and compile it etc, could somebody be kind enough to check out my chip configurations please. I'm using a 16F767 PIC.

I'm not sure what to do for the following and why;

Oscillator settings
MCLR settings
BOR Voltage settings.
CCP2 MUX PIN settings.

Bearing in mind I will be ICSP with a PICKIT 2. (Attached is the program )

Thanks a Lot...John
Attachments
SERVO PROGRAM 5.fcf
(10.5 KiB) Downloaded 820 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Servo Program Settings

Post by Benj »

Hi John,

Can you tell us how your hardware is setup to get the configuration right?

What crystal speed are you using? Are you using a crystal?
Do you need the MCLR pin as a reset pin or a digital input?
Do you need the chip to brown out (reset) to avoid potential dodgy operation when the power supply is dipping.
Do you need PWM channel 2 on a specific pin?

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Hi Benj, thanks very much for answering my call for help.

I wont be using a crystal at all and hope to run the chip at 4MHz using internal setting?

The MCLR pin I will not be using. If I understand the datasheet correctly, the MCLR pin need to be pulled up to 5V with a resistor greater than 1K in value. I've used a 10K resistor. This is reflected in my schematic.

I think I set the BROWN OUT to 2V as I think this is the lowest voltage the chip will run on as per datasheet?

I do not need the PWM channel 2 on a specific pin at this stage. I've allocated the servo signal pin to pin 2 on the chip. Is this OK?

At a later stage, I hope to incorporate a potentiometer that will control the speed that the servo swipes back and forth (within its limits of course)

Sorry, I could not attach the 16F767 datasheet as it was too large.

I've attached two drawings so you can see what I have done so far and where I have gone wrong. One drawing of how I connect the chip 16F767 to my PICKIT 2 programmer, and the other of the actual circuit for controlling the servo. All comments are appreciated.

Thanks very much for your time..........John
Attachments
SERVO SCH 2.jpg
SERVO SCH 2.jpg (27.26 KiB) Viewed 22265 times
PICKIT 2 ICSP 16F767.jpg
PICKIT 2 ICSP 16F767.jpg (28.25 KiB) Viewed 22270 times

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Here are the configuration settings I have done so far.

INTRC CLOCK OUT - To run the chip on its internal RC clock.

MCLR PIN = As a MCLR pin as I do not need it as a digital input at this stage. When inserted into the actual circuit I have tied it to VDD by way of a 10K resistor as per datasheet.

BOR- Set it to 2.0V, safe voltage to run Vdd down to?
PWM 2 - Dont need it set to any PWM channel as the servo signal wire is connected to PIN 2 (RA0/AN0)on the chip. ?????

Any help is appreciated........John
Attachments
16F767 ConfigB.jpg
16F767 ConfigB.jpg (69.42 KiB) Viewed 22254 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: Servo Program Settings

Post by medelec35 »

Hi John.
Using INTRC as clock out just means port the clock frequency is present on RA6.
If you wish to use RA6 as I/O pin at some point,then just select INRC as port I/O
I believe the default internal clock frequency is 31.25KHz.
So you will need to add to the very start of main a C code block with

Code: Select all

osccon=0x60;
Then should be good to go.
It's always good practice before using any components that is vital on the timing e.g. servo's LCD's timer interrupts etc.
To do a 1 second flash test first.
Can save a load of headaches and time in the long run.
For more advice you can also look here

Looking at your flowchart it looking like you have thought of this but will leave comments in as it may help others.
Also you don't need to keep calling the servo enable.
Since you don't have servo disabled you can place enable after osccon C code block and before start of main.
If you are still stuck then if you post a flowchart, we can look at it for you.

Martin
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Thanks Martin, I'll check out your comments and post either late tonight or Sunday sometime.

Thanks for your time............John

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Hi Martin, tried the program but nothing worked. So, I decided to start from the very begining again and simply get the chip to flash a single LED in the hope to see if my programmer is programming OK.

Well that did not work either. I have checked it over but am clearly missing something. Theres also a photograph of how I have connected the PICKIT 2 programmer to my 16F767 chip.

I would appreciate it if you or anybody else would take a look at the atchments and point out where I have gone wrong please.

Thanks for your time .......John
Attachments
767-Compiler & Programmer Settings.jpg
767-Compiler & Programmer Settings.jpg (70.69 KiB) Viewed 22165 times
16F767 ConfigB.jpg
16F767 ConfigB.jpg (69.42 KiB) Viewed 22165 times
ICSP-16F767.JPG
(395.94 KiB) Downloaded 8657 times

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Here is the program for the LED flash test.
Attachments
ICSP -767 LED Flash Test.fcf
(6 KiB) Downloaded 839 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Servo Program Settings

Post by kersing »

Can you program the chip without errors?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

I can do the compiling to C and the compile to Hex with no error messages.

When I go to burn the chip that also happens with no errors at all. But, what I did notice is;

Need to use the PICKT2 software to turn target light on programmer on.
When I try and burn the chip, there is no red busy light flickering like it usually does.

I have read that sometimes PICKIT2 programmer cannot supply the correct voltage to the chip(THINK IT WAS ABOUT 4.75V) and that an external 5V supply should be connected.Does this mean I can connect an external supply to Vdd via a 100 ohm resistor and ground to Vss. Will this not cause any damage to my programmer or chip????

Any ideas?????

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Servo Program Settings

Post by kersing »

Connect an external power supply to Vdd and Vss pins. Connect PICkit2 Vdd with 100 Ohm resistor to Vdd pin. Make sure to set PICkit2 not to supply voltage to the circuit/chip, the command line in your screen shot sets PICkit2 to supply 5 volts (-A5 argument).
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Thanks kersing,I'll give it a go and let you know the results.

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Tried connecting the chip up to a seperate 5V power supply but still did not work. Target light on the programmer is on but the programmers red busy led does not come on when choosing to burn the chip.

I meant to mention, the only way I can get power(5v) to come on via programmer is if I open the PICKIT2 software up and tick the Vdd box for on.

I've attached a schematic as to how I inserted the 100 ohm resistor for you to check I did it correctly.
Thanks again......John
Attachments
PICKIT2 ICSP Connection.jpg
PICKIT2 ICSP Connection.jpg (19.92 KiB) Viewed 22081 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: Servo Program Settings

Post by medelec35 »

Hi John,
Sounds to me like flowcode is unable to directly communicate with PICkit programmer.
When it does and programs target device you should see:
http://www.matrixtsl.com/mmforums/viewt ... 22&#p57993
If you go to where you flowchart is stored/compiled and post the file that contains .msg.txt
E.g

Code: Select all

SERVO PROGRAM 5.msg.txt
Then we may see whats going on?
Its possible that an antivirus or firewall is preventing access?
What antivirus and firewall do you have?

What I do when programming is during compiling lookout for the following symbols to appear(at least forward slashes):
symbols.png
(498 Bytes) Downloaded 16285 times
Then I know all has gone well!


Martin
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Hi Martin, I have attached the .msg file for your perusal.

I did not get the sysmbols you showed in your last post.

I am using ESET Smart Security 8. While you peruse the attached file, I'll find out how I can disable the antivirus. As far as the firewall, the only one I know of is the one that comes standard with WINDOWS VISTA.
Attachments
ICSP -767 LED Flash Test.msg.txt
(726 Bytes) Downloaded 415 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: Servo Program Settings

Post by medelec35 »

Hi John,
Can you rename your Flowchart removing the - and try again.
E.g try renaming to ICSP 767 LED Flash Test
or ICSP_767_LED_Flash_Test
Or just something much more basic and less characters.

I don't think pickit2 likes the file name

Martin
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

OK I'll do that. In the mean time here is the message I get when the programming doent happen. It says that the hex file was not tranfered etc.
Attachments
16F767 Programming Message.jpg
(69.33 KiB) Downloaded 8545 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: Servo Program Settings

Post by medelec35 »

HI John,
JDR04 wrote:In the mean time here is the message I get when the programming doent happen. It says that the hex file was not tranfered etc.
I saw that message as its contained within ICSP -767 LED Flash Test.msg.txt you posted.
That's why I have said about the file name.
I don't believe its the antivirus etc and leaning towards the file name after looking at the contents of the msg.txt

After renaming,
If you still get no joy then I will conduct some of my own experiments with PICkit2
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

OK, seems you were spot on about the file name,changed the file name and everything seemed to work. Target light was on, Red led came on when programming.

LED not flashing though. Tried pulling MCLR up to 5V but that did not work either.

I'll redo my hardware later tonignt and post a photo for you to look at.

Thanks for you time..........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: Servo Program Settings

Post by medelec35 »

Hi John,
No problem.
At least you'e getting further.
What I do when designing a circuit with a microcontroller is include the ISCP as part as the whole circuit.
If you look at PICkit 2 USER'S GUIDE page 27
You can see how to connected up additional applications.
You can even use data and clock pins for inputs and outputs so long as if connected to say a pot then the resistor shown must be included.
Then you won't have to remove chip or components when/after programming.

Martin
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Hi, have inserted the circuitry for MCLR pin and tried to reprogram, LED came on but nothing further. Also tried disconnecting MCLR circuitry still nothing. Then changed MCLR pin to RC3 in the configuration settings still nothing.

I must be doing something wrong on the hardware side I think so I have attached a photo of my set up for your perusal. Its macro mode so it is rather large but easier to see.

Thanks guys...............John
Attachments
767 CIRCUIT.jpg
(511.6 KiB) Downloaded 8481 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: Servo Program Settings

Post by medelec35 »

Did you add the c code block

Code: Select all

osccon=0x60;
at the very start?
If LED stays lit your clock could be running very slowly indeed!
Perhaps if you post the flowchart your are using and the hex file I can take a look for you
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Sorry, forgot the extra C Code in the beginning. Done now but LED wont flash

Will attach my flowchart and the hex file for you.

Thanks a lot....John
Attachments
LED Flash Test.hex
(908 Bytes) Downloaded 494 times
LED Flash Test.fcf
(6 KiB) Downloaded 771 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: Servo Program Settings

Post by medelec35 »

Hi John,
The only issue is you have the clock speed left on the default 19660800Hz when is should have been set to 4000000Hz since osccon=0x60; forces internal clock to run at 4000000Hz
The only difference it should make is LED flashes every 4 seconds instead of ever second.
But instead of setting to 4MHz I have decided to run clock at double the speed i.e. 8MHz
So I have changed clock speed to 8000000Hz and changed osccon to 0x70;
you don't need pull-up resistor on MCLR pin if RE3/MCLR is set to RE3.
Since pin 1 has been forced to change from clear to RE3 input.
Attachments
LED Flash Test2.fcf
(6 KiB) Downloaded 771 times
Martin

JDR04
Posts: 271
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Servo Program Settings

Post by JDR04 »

Nope, nothing happened.

There was an error message when the program ming finnished. I've attached it for you to look at.

I dont know if its worth mentioning, when I open up the PICKIT 2 software, I get a confirmation of the programmer connected OK but no chip is found. Hope this helps.

If it flashes with your PICKIT2 programmer then it must be something I am doing wrong on the hardware side????????????

Thanks again.....John
Attachments
Martin LED Flash Test2.hex
(792 Bytes) Downloaded 491 times
Martin LED Flash Test2.fcf
(6 KiB) Downloaded 763 times

Post Reply