• AVR Freaks

Hot!I need some help with PIC programming

New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2018/11/24 14:52:42
  • Location: 0
  • Status: offline
2019/06/17 07:14:24 (permalink)

I need some help with PIC programming

Hey Guys!
I'm pretty new to these PICs, recently I worked a bit with arduinos, but nothing else.

My idea would be that I need an electronics for kinda a signal passthrough. There is a slide potentiometer which works from 20 to 50ohms. There is 1.080.000 signals going into the PIC at a second(18.000/min). My Idea would be that when the slider hits 30ohms every 3rd signal gets "trapped". So from 3 signal there is just only 2 passing out from the PIC. And when the slider goes under 30 ohms it passes through again every signal. The most Important thing is that there can't be ANY delay to it. 
Is it possible to do it with PICs? Or there are more simple ways to it?(the signal is from an ignition, from the inductive Pick-up)

Sorry for my English, I'm Hungarian 

3 Replies Related Threads

    Aussie Susan
    Super Member
    • Total Posts : 3708
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: I need some help with PIC programming 2019/06/18 20:45:58 (permalink)
    5 (1)
    I don't understand your numbers but if by "1.080.000 ... a second" you mean that the MCU has to respond to just over 1 million pulses a second (about 1 every uS) then you are going to need a very fast device and I'm not sure if many Microchip MCUs have a clock speed greater than about 160MHz (about 80MIPS).
    On the other hand if the "18.000/min" refers to 18 thousand revolutions a minute with one pulse per revolution (300 pulses per second or one every 3.3mS) then that should be easily done.
    The ADC in the MCUs measure voltage and so what really matters is the voltage that you are applying across the potentiometer and the voltage on the wiper when it at the required place.
    Counting the pulses and then stopping one every three should not be a problem, as long as the above are taken into consideration.
    The biggest problem you will face is "...there can't be ANY delay...". There will ALWAYS be a delay! Logic gates might measure the delays in nS or pS but it will be there. Using an MCU you are limited to how fast the instructions are executed and how many instructions you need, plus various overheads (e.g. if you are using interrupts).
    Therefore, what is the actual delay that you can withstand? If this is for a physical motor then I would have thought you could withstand 10's of uS delay at least.
    What I really suggest you do it so start with a 'flash a LED' project. The learning curve for the Microchip MCUs can be quite steep to get the first bit of code working (configure the IO ports, the oscillator, the CONFIG settings, and then getting the code programmed into the device and perhaps debugged). The good news is that once you have that working then the basic 'mechanics' is done and you can start to build up to the actual application yo have in mind.
    Super Member
    • Total Posts : 26968
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: I need some help with PIC programming 2019/06/18 21:20:23 (permalink)
    If those numbers are actually 18,000 and 1,800,000 (i.e. European convention swapping '.' and ','
    then 18,000 * 60 = 1,080,000
    but the "per second" and "per minute" are back to front.

    The most Important thing is that there can't be ANY delay to it.

    As Susan stated, this is a ridiculous requirement. There is always some delay, governed by the speed of light.
    It is your job as an engineer to specify how big a delay is acceptable, using real, hard numbers.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    Super Member
    • Total Posts : 355
    • Reward points : 0
    • Joined: 2019/04/16 22:01:25
    • Location: 0
    • Status: online
    Re: I need some help with PIC programming 2019/06/19 05:58:18 (permalink)
    It is called a gated clock demultiplexer and its done with discrete logic but you can control it with a processor. It is used a fair bit it high speed RF comms and radar.
    If you look at something like an old 4017 counter or any ripple counter you can setup to divid by n mode.
    Look here
    So if you want to remove every 3rd pulse you connect Q3 to the reset.
    Now Q2 on the 4017 chip goes high between the falling edge of the 2nd clock and the falling edge of the 3rd clock so if you feed Q2 and the Clock itself to an NOR gate it effectively gates every 3rd pulse out.
    So if you consider the output of Q2 of 4017 as "A" and look at the NOR logic below you can see as long as it is high (1) the output can only ever be low so any clock signal coming into B never makes it out the NOR gate. Alternatively whenever "A" is low (which is all other counts on the 4017) the output just inverts whatever is on B. So you send the clock to the 4017 and then thru a simple inverter and onto B on the NOR gate. 
    The logic for NOR is

    So all it is doing is basically blocking the clock pulse based on clock count. The only delay is whatever the NOR gate delay is which is sub nano second down to picoseconds depending what speed grade IC you choose.
    That is the theory and there are a million ways to do it.
    Jump to:
    © 2020 APG vNext Commercial Version 4.5