Maker Pro
Maker Pro

Microcontroller controlled by pushbutton for LED flashlight

Ok I had a spare 5 mins from decorating (The misses went out) :) and I am happy with the off response now. I couldn't get the timer working which would have made the code much simpler. I will look at getting some other 10 series of PICs which have a better core and see if I can work on some better code.

I still have to get the sleep working but you can have a play with the code. We may need to adjust the off time or to charge the capacitor and you may need a larger value.

If we have problems with this we may need to power the PCB initially from a battery just to get it working and see if your happy with the timings. I have attached the project from MPLAB 8.63. the .asm file is where the code is but I have attached some picture for others that might be interested. I am not a programmer so I have done my best at the moment for you.

Cheers
Adam




Code1.PNG Code2.PNG Code3.PNG Code4.PNG Code5.PNG Code6.PNG Code7.PNG Code8.PNG
 

Attachments

  • FLASH_LIGHT.zip
    14.6 KB · Views: 60
Thanks, what do i do with this? Load the hex file in MPLAB IPE and hit program? Anything after that? Do I need to tell the pic to "run"? Unfortunately, the code is just gibberish to me. In this version, what is the time on/time off ratio? 100 to 1?
 
Hi Jeff
Open the project (mcp file) in MPLAB. You should see the asm file, click on this so you can see the code. Build the code and then program. I dont use MPLAB X so not sure what to do but the menu buttons should be similar. Put your mouse over the symbols on the task bar to see what they say. Look for build or compile and then program should be in the programmer tab. Else download 8.63 IDE from microchip. I just searched old MPLAB version in google.
Adam
 
Last edited:
I also noticed that in the pinout definition in the asm file that you have GP0 assigned to transistor on/off and GP2 not used. On my PIC/circuit board, GP0 is not used and GP2 is connected to the MOSFET gate.
 

hevans1944

Hop - AC8NS
MPLAB 8.63 is for 32 bit OS. All my machines have 64 bit OS running.
What machines and which OS are you using? I am using an HP Pavillion-series laptop running 64=bit Windows 7 Professional and have had no problems running 32-bit programs. I will download MPLAB later this week to see what happens in my environment and let you know what I find out.

I today downloaded the datasheet for the PIC10F2xx series, so as to try to figure out what Adam's program does. You might want to do the same thing.
 
I also noticed that in the pinout definition in the asm file that you have GP0 assigned to transistor on/off and GP2 not used. On my PIC/circuit board, GP0 is not used and GP2 is connected to the MOSFET gate.
Oh ok I must have mixed up the pins. I think you can do a find and replace all. I will have a look later. Otherwise we just need to change the ,0 to ,2 for all the bcf and bsf.
Adam
 
What machines and which OS are you using? I am using an HP Pavillion-series laptop running 64=bit Windows 7 Professional and have had no problems running 32-bit programs. I will download MPLAB later this week to see what happens in my environment and let you know what I find out.

I today downloaded the datasheet for the PIC10F2xx series, so as to try to figure out what Adam's program does. You might want to do the same thing.

Thanks Hop.
 
The build icon is the hammer. It is greyed out and does nothing. All of the icons are greyed out.
Looks like you need to select a compiler for the project. Instead of trying to tweak all the settings which could take awhile, just copy all of the code and start a new project then paste the code into it.

To start a new project in MPLAB X:
Click on File->New Project. The new project Wizard will open.
The Wizard will tell you to select a project: click Microchip Embedded -> Standalone Project.
It will now ask you to select a PIC - Select the PIC10F200 from the drop down menus. Click next.
Now it will ask you to select a debug header, the default should be none, so click next.
And now it will ask you to select a tool, select the PICKIT 3 and click next.
It will now ask to select a compiler, select the mpasm one and click next.
Now it will ask for a project name, name it what ever you want and click finish.

Now that you have created a project it should be showing on the left side of MPLAB under the projects tab. There should be a folder under your projects name that says "Source Files". If so, then left click on it, and go under "New" and click "Other". A new window will pop up and you should see a folder named "Assembly File" in it. If so, then click on it and under it you should see an option "AssemblyFile.asm" click on that and then hit next. Now it will ask you to name it usually people call it "main" but call it what you want and click Finish.

It should now open the file you just created, and you can paste Adams code into it. You should now be able to build it, and program it into you chip.

As for 32 bit programs on a 64 bit machine, they always have run fine on my tower with Windows 7 Ultimate. And from being a programer, 64 bit machines are made to also run win32 programs.

But if I where you I would just stick with MPLAB X, it really is a great program. :)
Dan
 

hevans1944

Hop - AC8NS
...But if I where you I would just stick with MPLAB X, it really is a great program. :)
I sure hope so. I sweated bullets last night waiting for all 360 Mbytes to download, hoping my Time-Warner wiseband wouldn't decide to throttle or cut me back to ADSL speed for no other reason than they can. I would upgrade from "Turbo" to 50 Mbps, but even that isn't guaranteed. So now I have it on my laptop, ready to copy to a USB memory stick.

I guess my next step is to purchase the genuine Microchip USB programming thingy and a few chips (with SMD carriers and pin connectors!) to play with. This side track is really cutting into my Arduino learning activity, but I want to try to help @zebeste (the wildlife biologist) with his timer project.

@TenderTendon : Make sure you are using the MPLAB X IDE. There is a new version 3.00 coming in April, but the beta version is available now. I would wait for the release version instead of downloading the beta. No need to complicate your life.

73 de AC8NS
Hop
 
I am using MPLAB X IDE v2.30. I downloaded the datasheet long ago. I made several attempts to grasp the concept of operation. The furthest I got is understanding the pinouts. Anything beyond that gives me a headache. I'm sorry, but I honestly don't have the time or capacity to learn programming these. I work 70-80 hours every week. The time I have already spent on making PCB's has put me behind.
 
We will all help you as much as we can. It's very difficult to do this over the internet. I have spent 20 hours of my own time on this. I also work, not as many as you I must admit. When you do have time it is worth getting to know the datasheet a bit. It make it easier to make changes to the code. You did say make me a programming guru :)
Cheers
Adam
 
We will all help you as much as we can. It's very difficult to do this over the internet. I have spent 20 hours of my own time on this. I also work, not as many as you I must admit. When you do have time it is worth getting to know the datasheet a bit. It make it easier to make changes to the code. You did say make me a programming guru :)
Cheers
Adam

20 hours... Sorry about that. I never expected anyone to dedicate that much time to this and am feeling very guilty asking for any more help. Perhaps it is best that we all not invest any more time into it. Thank you again for all the time spent.
 
Why? I don't mind really. Don't feel guilty. The work that earns you money is more important. We will get this working even if I have to make some PCBs myself and send them over to you. This means so much to me as I really thought a lot of Kris and still do.

One other idea I have had is maybe @Supercap2F could do a log me in with you. It's a remote assistance package which allows other people to control your PC.

Adam
 

hevans1944

Hop - AC8NS
... I'm sorry, but I honestly don't have the time or capacity to learn programming these. I work 70-80 hours every week. The time I have already spent on making PCB's has put me behind.
I can appreciate that. Gotta put food on the table first. Learning how to program is a luxury for those of us with some time on our hands. I don't keep track of the hours I spend on my electronics hobbies or trying to help others in this forum: every one of those hours spent is a blessing, and I am just "paying forward" what others over the years have done for me. Adam (@Arouse1973) is here to help, and I am sure there are others... myself included, as soon as I get over the top of this current learning curve.

Since we both live in the States, I might be able to help you with a faster turn-around time than Adam can. Maybe even a telephone conversation would help (I have unlimited free long distance in the USA on my Sprint cell phone). However, this PIC stuff is all new to me too... plus my skills as a programmer are not exactly world class... sort of on par with my skills as a woodworker and amateur machinist: I butcher wood, make curly metal shavings, and hack away at code until it eventually works. And all I know about flashlights is what I can buy at Lowe's, and that they are incredibly bright nowadays. Battery life still sucks.

Since you already have a populated board prototype made (it's just not the right size to fit in the base of a flashlight yet), you should be able to wrap this project up "real soon now". I am going to order some "stuff" from either Digi-Key or Microchip this week to play with, so put your project on the back burner for a week or so until I can get up to speed on the Microchip PIC family.

Meanwhile, I don't know what to tell you about why MPLAB X IDE doesn't appear to work on your computer. It appears you have the latest release. Maybe there is something wrong with your PICKit 3 programmer/debugger? I don't have one of these yet, but it will be part of my online order this week. Some people here have had problems with USB-to-serial interface chips and drivers, but I would not imagine that would be a problem with a genuine Microchip product. Still, if you are using Windoze, check in Device Manager to see if the PICKit 3 is recognized as a COM port by the OS when it is plugged into a USB port on your computer.
 
Thanks Hop

I am glad your here to help, thank-you very much. Just let me know if there is something you don't understand about PICs they can be a bit tricky at times. I know Bob @BobK has a great deal of experience with PICs maybe he can help if he has time. We are all in this together I feel and Kris would have been proud of us. I would however do this again, it's just seems a fitting purpose. I really do like helping people if I can. As I say I am not a programmer by trade so to someone that can this might look like a bag of shite. :)

Thanks
Adam
 
Top