Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16F630 coding needed

Status
Not open for further replies.
Mike.
If this is the only function u want to use this device for just solder a new Quartz Crystal half the speed of current one and see what happens. This way you will get double the timing values and you wont need any additional programming.

A super idea! This will be a plan "B".
Tks
 
Last edited by a moderator:
Have you actually tried programming it with the two sets of switch info in the manner I said in my last post said:
The time scales/ranges in my doc file are what I want, not how the unit was supplied; or there would be nothing to do!
 
Well I may be a but slow on the uptake so have to know ask clearly -

Is the unit you have a new one from CanaKit ? - as a kit or ready made ? or as a second hand built unit from somewhere.

From your description its now sounding like the hardware is faulty if its not working as per the instruction sheet.

Assuming it cannot be returned to Canakit as faulty ?

If the hardware is faulty then it would seem pointless trying to program it with some other program, as who knows where the boards fault may be.

If you are wanting a program to run on a micro to give you the 40m /10sec times your are after thats quiet easy and those times could be changed by simple changes to the software , as simple as changed ontime = 40 to ontime =45 .. etc.

If you are still wanting something to run with hardware switches for timing then that a bit more complicated, and give your board may be faulty a bit of a fruitless exercise.

Can you say what country or continent you are in.
 
Well I may be a but slow on the uptake so have to know ask clearly -
Is the unit you have a new one from CanaKit ? - as a kit or ready made ? or as a second hand built unit from somewhere.
It is a new kit I built.
From your description its now sounding like the hardware is faulty if its not working as per the instruction sheet.
Why does it sound faulty? It is working exactly as it supposed to.
Assuming it cannot be returned to Canakit as faulty ?
If the hardware is faulty then it would seem pointless trying to program it with some other program, as who knows where the boards fault may be.
If you are wanting a program to run on a micro to give you the 40m /10sec times your are after thats quiet easy and those times could be changed by simple changes to the software , as simple as changed ontime = 40 to ontime =45 .. etc.

Please explain "simple changes to the software". THIS IS NOT POSSIBLE, THE CODE IS PROTECTED!
If you are still wanting something to run with hardware switches for timing then that a bit more complicated, and give your board may be faulty a bit of a fruitless exercise.

Can you say what country or continent you are in.
I am in Canada (CanaKit = CanadaKit)

** I have updated my info file to include the original configuration **
 
Last edited:
From your description its now sounding like the hardware is faulty if its not working as per the instruction sheet.
Why does it sound faulty? It is working exactly as it supposed to.

Currently, the function is as follows: each set of DIP switches can be set for seconds, minutes, or hours (red=on time, blue=off time ); Then they are set for the actual times, but since there are only 4 switches counting in binary, the highest times = 15. ie 1s - 15s 1m - 15m 1h - 15h']Currently, the function is as follows: each set of DIP switches can be set for seconds, minutes, or hours (red=on time, blue=off time ); Then they are set for the actual times, but since there are only 4 switches counting in binary, the highest times = 15. ie 1s - 15s 1m - 15m 1h - 15h


I can only go on the information you give , but I really think you have misunderstood how the switches set up the times.

To me it is clear from all those links and documents that the kit can do what ever times you need.

I suspect that lines like this have caused to you , mistakenly think it can only do 1 to 15.

Each DIP switch can be set to a binary value of 1 through 15 and can be configured to be in Seconds, Minutes, or Hours.

Thats not the case, it means you have 15 possible combinations of the 4 switches, BUT each position of the switch refers to at time as per those charts on the right hand side.

As an example

To set the RED on time for 40 mins.

First you must set the switches to select the time range for the 40 mins you want from the 8 - 120min range, so set switches 1-3 down and 4 up.
Do the same with the Blue switch for your off time range.
Then power up with the black switch pressed and you should see the led flash to say its accepted the Time Range.


Power off and then set the Red switches for the time you want.
Look at that 8-120 min chart and against the 40 mins you see the four settings for the Red switch so set 1 and 3 down and 2 and 4 up.
Do the same for your Blue Switch actual time.
Then power on and it should run for 40 mins .

Please do actually try it, I'm not there , but feel sure thats the correct way to get it working properly


Edit, the timing details in that document, where it says 8 -120 mins there is a little picture of the dip switch positions that for telling it to select the 8 -120m range.

The chart on the right is for setting the switches again for which one of the 16 times times you want from that range , so the 40 mins shows the required position of the switches
 
Last edited by a moderator:
I can only go on the information you give , but I really think you have misunderstood how the switches set up the times.

To me it is clear from all those links and documents that the kit can do what ever times you need.

I suspect that lines like this have caused to you , mistakenly think it can only do 1 to 15.

Each DIP switch can be set to a binary value of 1 through 15 and can be configured to be in Seconds, Minutes, or Hours.

Thats not the case, it means you have 15 possible combinations of the 4 switches, BUT each position of the switch refers to at time as per those charts on the right hand side.

As an example

To set the RED on time for 40 mins. First you must set the switches to select the time range for the 40 mins you want from the 8 - 120min range

YOU ARE LOOKING AT THE CHARTS I WOULD LIKE TO HAVE. There is no 8-120min range.
THIS IS NOT THE CURRENT (ORIGINAL) CONFIGURATION.
I have modified my doc file to include the original (current) configuration.
 
Last edited:
Well the original document you posted looked like the kits actual datasheet, hence my misunderstanding .

Assume you have some more 16f630 chips ready to reprogram with ?

You also need to read and supply the value that should be on the top or side of the crystal, thats the silver can behind the Red switch.
It may have a simple value like 8Mhz or it could be something like 32678hz.
That sets all the timing references for anyone coding a program.

Seems like there are 3 programing options;-

A fixed time program to give your exact dehumidifier times. very easy to program.

An open source program code where you can easily specify the exact times you want in secs and minute and hours, though that would require you to run a PC program to enter the data and compile the program ready for the PK1, just a 5 min job for you. Quiet easy to write the program.

To reprogram to use the switches in the manner you want, with its two level switch programming, is possible but a lot more time to write the program.

If you have some 16f630 chips ready I could send you a 40m on 10sec off fixed .hex program for you to directly burn in with the Pk1 and check it runs ok on your circuit.
The new chips would not be code protected so you can readily read back ,erase or reprogram the chip.

If that works then you you at least have the working dhum system you want.
 
He has edited and posted it in his first post!!!

I have also written some code.... I have used your exact timings.... 1 ~ 15secs... 1 ~ 15mins... 2 ~ 30mins and 8 ~ 120mins..
The only thing I can't see what I've done wrong is... I can't get the weak pullups to work on PORTA..

There is scope for oodles more delay times....
 
Assume you have some more 16f630 chips ready to reprogram with ?
Yes I do
You also need to read and supply the value that should be on the top or side of the crystal, thats the silver can behind the Red switch.
It may have a simple value like 8Mhz or it could be something like 32678hz.
That sets all the timing references for anyone coding a program.
12MHz
Seems like there are 3 programing options;-
A fixed time program to give your exact dehumidifier times. very easy to program.

An open source program code where you can easily specify the exact times you want in secs and minute and hours, though that would require you to run a PC program to enter the data and compile the program ready for the PK1, just a 5 min job for you. Quiet easy to write the program.
This could be a first step to get going, but I would like to have the flexibility of the switches to be able to make quick changes depending on the humidity at different times of the year.
To reprogram to use the switches in the manner you want, with its two level switch programming, is possible but a lot more time to write the program.

If you have some 16f630 chips ready I could send you a 40m on 10sec off fixed .hex program for you to directly burn in with the Pk1 and check it runs ok on your circuit. The new chips would not be code protected so you can readily read back ,erase or reprogram the chip.
Start with 30 min on, 5 sec off.
If that works then you you at least have the working dhum system you want.
Tks very much!!
 
Last edited:
As you will have seen, it sounds like Ian has almost written a proper 'switch' version for you.

You originally said you would prefer the code C, and as I only do Assembly, I think it would be much better if I deferred to Ians greater coding ability.

I'm sure you will be in very capable hands.
 
As you will have seen, it sounds like Ian has almost written a proper 'switch' version for you.

You originally said you would prefer the code C, and as I only do Assembly, I think it would be much better if I deferred to Ians greater coding ability.

I'm sure you will be in very capable hands.

C doesn't mean better!!! I found that Proteus has a bug... The program does indeed work with the internal pullups..

The only things left to know is.... Oscillator ???? and which dip switch is red and which is blue??? I'm assuming 4Mhz and the red dip is on PORTA????
 
Ian,

The Osc is 12mhz as he specified in #30, though seems odd being as the chip has a 4mhz internal osc

The weak pull ups on PortA, they are globally controlled by the RAPU (low) bit of the option register, bit 7, which power on defaults to 1.

Red is the On Time and Blue is the Off Time, but yes the O/P needs to send a pic of the track side as those 4 resistors could be on either switch.
 
Ian,

The Osc is 12mhz as he specified in #30, though seems odd being as the chip has a 4mhz internal osc
Cheers!
The weak pull ups on PortA, they are globally controlled by the RAPU (low) bit of the option register, bit 7, which power on defaults to 1.
Yep!! I was using an old copy (V7) of Proteus... Once I tried t on V8 it came right!

ed is the On Time and Blue is the Off Time, but yes the O/P needs to send a pic of the track side as those 4 resistors could be on either switch.

That is what I assumed...
 
Cheers!

Yep!! I was using an old copy (V7) of Proteus... Once I tried t on V8 it came right!
That is what I assumed...
Does anyone need the layout of the PCB? I scanned both sides before building it.
 

Attachments

  • PCB back.jpg
    PCB back.jpg
    90.8 KB · Views: 218
  • PCB front.jpg
    PCB front.jpg
    149.5 KB · Views: 230
What the b'geebers is pickit1...

(gone away to find out )...
....
( back again )...
According to MPLAB IDE v8.92 pickit 1 supports this chip....

To program the chip you need the HEX file.... If you want to make changes to the C source code, you'll need XC8 lite ( or the Pro is available for 30 days...

Instructions... The way I read it....

Set the switches to determine the base timer..
Press the switch whilst powering up...
The LED flashes twice to acknowledge the new time base....
Reset the dip switches for the timer period within that time base..
Reboot without the switch press...
On time and off time continuous operation..

** Files removed
 
Last edited:
Instructions... The way I read it....
Set the switches to determine the base timer..
Press the switch whilst powering up...
The LED flashes twice to acknowledge the new time base....
Reset the dip switches for the timer period within that time base..
Reboot without the switch press...
On time and off time continuous operation..
Ian:
Sorry to say it, but the timer does nothing.
Writing to a virgin chip was seccessful. So was verifying (see attached).
There is a fast weak flash from the LED when I apply the power, both in config and run mode, but that's all. Its too fast for the relay to react.
???????
 

Attachments

  • write.jpg
    write.jpg
    84.2 KB · Views: 206
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top