How Can I Efficiently Program the PIC18F2520 for Money Detection and Validation?

  • Thread starter Machtig
  • Start date
In summary, the person is looking for help to program the Pic18f2520 for a project and is looking for references or tutorials.
  • #1
Machtig
2
1
hello everyone,
I currently have to learn how to program the pic18f2520 for a project and I need to do it fast. So I was wondering if anyone has any reference (other than the datasheet of course) that can help me to learn or even any advice.

thank you
 
Engineering news on Phys.org
  • #2
Machtig said:
hello everyone,
I currently have to learn how to program the pic18f2520 for a project and I need to do it fast. So I was wondering if anyone has any reference (other than the datasheet of course) that can help me to learn or even any advice.

thank you
Welcome to the PF.

What have you found in your searching so far? I'd imagine there are probably some good tutorials on the Microchip website. What development environment are you using? What language are you programming in? How much experience do you have with programming and microcontrollers (uCs)?
 
  • #3
Also, what is the project? Are you loading your code into a Development Board (if so, which one?), or into existing hardware with that uC on it? What peripherals will you be interfacing with?
 
  • #4
I learned to program in C at the same time as learning my first microcontroller which was the 18F2520. It's not likely something that will be quick and easy for you. I spent a lot of time reading. Just learning to navigate MPLAB was enough to make me want to turn away. I wanted it bad enough though, so I stuck with it. What is the project? Are you using mostly peripherals on chip or wiring to other devices?
-
My 'developement board' was a proto board with the 2520 wired up to a graphics display module. I went from there.
 
  • Like
Likes berkeman
  • #5
There's no quick way to learn computer basics. Best way is to dive in as you are doing. Take it home over the weekend and plan on a lot of midnight oil.
Start with the examples on Microchip site.

If you are facing a project deadline consider using a BASIC micro instead. The interpreted Basic runs slow but is orders of magnitude easier to learn.

I used one of these for an emergency project -
http://www.micromint.com/products/by-family/modules.html?id=45
upload_2017-11-23_9-54-48.png


Had one week to order parts, design, build, program, debug and deliver. Made it thanks to the Boss's credit card and Steve Ciarcia's advice "Use Basic not assembly" .

old jim
 

Attachments

  • upload_2017-11-23_9-54-48.png
    upload_2017-11-23_9-54-48.png
    32.4 KB · Views: 452
Last edited:
  • Like
Likes dlgoff and berkeman
  • #6
Purchase the following items:
Explorer 8 Eval board $78
Pickit3 $48
You can get these directly from Microchip, or from Digikey, Mouser etc.
Download and start getting familiar with the MPLAB sofware.

As the others mentioned, expect to burn some midnight oil. That's how a lot of us got up to speed on this stuff.
That said, be grateful that you are starting out with PIC, the alternatives have a steeper, less user friendly learning curve.

The overall process consists of the following:
1 - Architect the design (has this been done?)
Diagram out exactly how the uC is going to solve the problem at hand. What will the timers be used for. What will the ISRs need to do.
Don't assume you need a complicated RTOS, will a simple cyclic executive suffice? Keep it as simple as possible.

2- If you are unfamilar with C, learn it. You do not want to program this in assembly unless you need to for performance reasons. One of the the big advantages of the PIC18 series is the deep hardware stack which makes structured C programming possible, you don't have to worry if adding another function call will overflow the stack.

3 - Use a hardware abstraction layer. Create functions that are meaningful to your application, readBatteryVolts(). Your hardware abstraction layer will map these to PIC functions, ADCC_GetSingleConversion(channel_ANA5). This will help you keep your sanity and will also facilitate any future port of this code to a different uC. Others may consider this bloat, but I think it is a good idea unless you are up against speed or space limits.

4 - Write your application code.

5 - Use MPLAB to create the hardware facing functions that you need, and tie them together in your hardware abstraction layer.

6 - Finally, and probably most importantly, if you run into a problem, use online searches and communities (such as this one) to get help. Almost any problem that you encounter, someone else has already encountered and gotten help online. Just be very specific in your queries.

P.S. If you have not built your hardware yet, make sure you provide access to the programming pins so that you can configure your target hardware with PICkit3.
 
Last edited:
  • Like
Likes berkeman, jim hardy, Averagesupernova and 1 other person
  • #7
Hello guys,

The project is a smart parkmeter that takes coins (2 types) and paper money (1 type) and detects when the car leaves.

We have to use pic18f2520, and the coding will be done with assembly using MPLAB.

So know our main concern is how to detect the money, we were thinking of having color detection and maybe having 2 slots using the dimensions of the coins.
So any ideas on that?
 
  • #8
Real product or school project?
 
  • #9
Machtig said:
So know our main concern is how to detect the money, we were thinking of having color detection and maybe having 2 slots using the dimensions of the coins.
So any ideas on that?
When you did your Google search on that, what did you find were typical techniques for money detection and validation? There is a LOT of information on this available...
 

FAQ: How Can I Efficiently Program the PIC18F2520 for Money Detection and Validation?

What is a Microchip PIC18F2520?

The Microchip PIC18F2520 is a microcontroller, which is a small computer on a single integrated circuit. It is commonly used in embedded systems and electronic devices to control their functions.

What is the difference between a microcontroller and a microprocessor?

A microcontroller, such as the PIC18F2520, contains not only a central processing unit (CPU) but also other components such as memory, input/output ports, and timers. A microprocessor, on the other hand, only contains the CPU and requires external components for other functions.

What are the main features of the PIC18F2520?

The PIC18F2520 has a 8-bit CPU, 32 KB of flash memory, 1536 bytes of RAM, and various communication interfaces such as SPI, I2C, and UART. It also has analog-to-digital converters and timers, making it suitable for a wide range of applications.

What programming language is used to program the PIC18F2520?

The PIC18F2520 can be programmed using the assembly language or a high-level language such as C. Microchip also provides its own programming language called PICBASIC for beginners.

What are some common applications of the PIC18F2520?

The PIC18F2520 is commonly used in consumer electronics, automotive systems, industrial control, and medical devices. It can be found in products such as home appliances, car engine controllers, and medical monitors.

Back
Top