Author Topic: 2 coding projects PIC help needed  (Read 506 times)

0 Members and 1 Guest are viewing this topic.

Offline MKRDTopic starter

  • Contributor
  • Posts: 42
  • Country: us
2 coding projects PIC help needed
« on: February 24, 2026, 04:51:10 pm »
Howdy,
I am looking for help on two hobby projects. PM cost estimate per each project. Code must be well-commented and will be shared to public's benefit.
1) First project is simpler and will warm us up before the bigger project. It is for an over-voltage clamp / motor regeneration brake resistor controller / ESTOP circuit.

Inputs:
Voltage input analog
ESTOP digital
Overtemp digital
Clamp voltage setting digital DIP slide switch combo

Outputs:
PWM output to MOSFET gate drive IC
LED: Fault, maybe others

Hardware:
One-off prototype, cost of MCU irrelevant to overall project, so can use fanciest 8-bit PIC.
PIC 8bit 16F or 18F expected, C language. Superloop.
ADC acquisition rate 1ksps minimum.
Loop time preferred on order of 10ms to catch fast overvoltage transients.

Initialize:
Set up MCU clock speed, set up ADC for continuous acquisition 1ksps.
Read DIP switch setting for OV clamp voltage.

Superloop:
If ESTOP is pressed, MCU to output 100% PWM duty, else
If overtemperature is detected at brake resistor or MOSFET, output 0% duty cycle, set LED fault, else
When ADC has completed acquisition, use LUT to determine PWM duty cycle.
Apply PWM duty cycle to output pin per LUT.
Loop.

It is a motor regeneration/braking overvoltage clamp circuit prototype, so up to let's say up to 48V is sensed by voltage divider, no action is needed, any voltage above 48V is treated as over-voltage in need of being clamped, 48V to 60V will be progressively increasing PWM duty cycle to attempt to clamp voltage, and if voltage reaches 60V, MOSFET+brake resistor will be 100% duty cycle. When regeneration voltage drops below threshold, circuit goes into standby.
« Last Edit: February 24, 2026, 05:15:14 pm by www.MKRD.info »
 

Offline MKRDTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: 2 coding projects PIC help needed
« Reply #1 on: February 24, 2026, 05:11:38 pm »
2) 2nd project much more complex, it would be an analog data concentrator. Timeline wise I have several months at least by the time it is needed and I need to lay out the PCB etc.
MCU choice after discussion, 32 bit full-featured MCUs like ARM acceptable, less powerful like PIC if you believe it will handle the project.
Superloop+interrupts may be sufficient, RTOS depends on discussion.

Inputs:
There will be up to a dozen analog inputs. To MCU they will be all voltages, real input will be voltages and temperatures from thermistors, etc. All to be continuously sampled at not faster than 10sps. All to be linearized and converted to engineering units using LUTs.
There will be up to a dozen digital inputs, consisting of safety switches. 10sps. All digitized to string/packet.

Outputs: there will be several digital outputs. Via buffering, the MCU will be controlling SSRs, LEDs, etc.

The main task of the MCU is to:
If ESTOP is set, make all relevant outputs safe.
Linearize all analog inputs via LUTs.
Pack up all inputs into a single packet. Add CRC.
Continuously stream packet of inputs over serial link. Any of RS-422/485/CAN/etc can be used, any of those can be read by LabVIEW that will be used to display all readings and make control decisions.
Continuously receive a packet of control statements over serial link. LabVIEW control logic + operator can make decisions. Control outputs after unpacking the packet of control bits received over serial link, if CRC is acceptable.
If serial communication time-out, WDT time-out, or POR occur, make relevant outputs safe.
Typical feature bloat like heartbeat LED, etc are expected.
Loop continuously.
« Last Edit: February 24, 2026, 10:12:11 pm by MKRD »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf