Servo Program Settings
Moderator: Benj
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Servo Program Settings
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
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 840 times
- 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
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?
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?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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
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 (27.26 KiB) Viewed 22802 times
-
- PICKIT 2 ICSP 16F767.jpg (28.25 KiB) Viewed 22807 times
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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
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 (69.42 KiB) Viewed 22791 times
-
- 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
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
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
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;
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
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
Thanks Martin, I'll check out your comments and post either late tonight or Sunday sometime.
Thanks for your time............John
Thanks for your time............John
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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
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 (70.69 KiB) Viewed 22702 times
-
- 16F767 ConfigB.jpg (69.42 KiB) Viewed 22702 times
-
- ICSP-16F767.JPG
- (395.94 KiB) Downloaded 8657 times
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
Here is the program for the LED flash test.
- Attachments
-
- ICSP -767 LED Flash Test.fcf
- (6 KiB) Downloaded 858 times
-
- 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
Can you program the chip without errors?
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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?????
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?????
-
- 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
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
― C.S. Lewis
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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
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 (19.92 KiB) Viewed 22618 times
-
- 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
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
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): Then I know all has gone well!
Martin
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
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): Then I know all has gone well!
Martin
Martin
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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.
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 425 times
-
- 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
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
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
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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
-
- 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
HI John,
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
I saw that message as its contained within ICSP -767 LED Flash Test.msg.txt you posted.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.
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
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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
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
-
- 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
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
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
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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
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
-
- 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
Did you add the c code block 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
Code: Select all
osccon=0x60;
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
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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
Will attach my flowchart and the hex file for you.
Thanks a lot....John
- Attachments
-
- LED Flash Test.hex
- (908 Bytes) Downloaded 514 times
-
- LED Flash Test.fcf
- (6 KiB) Downloaded 779 times
-
- 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
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.
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 803 times
Martin
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Servo Program Settings
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
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 499 times
-
- Martin LED Flash Test2.fcf
- (6 KiB) Downloaded 792 times