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

  • Thread starter Thread starter Machtig
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around programming the PIC18F2520 microcontroller for a project involving money detection and validation, specifically for a smart parking meter. Participants share their experiences, resources, and strategies for learning and implementing the necessary programming techniques.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant seeks references and advice for programming the PIC18F2520 quickly, indicating a need for resources beyond the datasheet.
  • Another participant suggests looking for tutorials on the Microchip website and inquires about the development environment and programming language being used.
  • Questions are raised about the specifics of the project, including whether the code will be loaded onto a development board or existing hardware, and what peripherals will be interfaced.
  • A participant shares their experience of learning to program in C alongside the PIC18F2520, emphasizing the time investment required and the challenges faced with the MPLAB environment.
  • Advice is given to consider using a BASIC microcontroller for quicker learning, especially under a tight deadline, with a reference to a specific product used in an emergency project.
  • Another participant recommends purchasing specific evaluation boards and tools, and outlines a general process for approaching the project, including architecture design and the use of a hardware abstraction layer.
  • A participant describes the project as a smart parking meter that detects two types of coins and one type of paper money, and discusses potential methods for money detection, such as color detection and dimensional analysis of coins.
  • Questions are posed regarding typical techniques for money detection and validation, prompting participants to consider existing information on the topic.

Areas of Agreement / Disagreement

Participants express a range of views on the best approaches to programming the PIC18F2520 and detecting money, with no consensus reached on specific methods or resources. The discussion remains open-ended with various suggestions and inquiries.

Contextual Notes

Participants highlight the importance of understanding the project requirements and the potential complexity of programming, indicating that assumptions about ease of learning may not hold true for everyone. There is also mention of the need for specific hardware configurations to facilitate programming.

Who May Find This Useful

Individuals interested in programming microcontrollers, particularly the PIC18F2520, as well as those working on projects involving money detection and validation in embedded systems.

Machtig
Messages
2
Reaction score
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
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)?
 
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?
 
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   Reactions: berkeman
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: 513
Last edited:
  • Like
Likes   Reactions: dlgoff and berkeman
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   Reactions: berkeman, jim hardy, Averagesupernova and 1 other person
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?
 
Real product or school project?
 
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...
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
Replies
7
Views
2K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
3
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
7
Views
3K
  • · Replies 15 ·
Replies
15
Views
5K
Replies
9
Views
3K
Replies
40
Views
4K