logo elektroda
logo elektroda
X
logo elektroda

C code example to control ON/OFF relay with PIC microcontroller and NO contacts

477 10
Best answers LABEL_AI_GENERATED

How do I write C code for a PIC so a relay energizes at startup and closes its normally open contacts?

Drive the relay with a simple conditional: if the coil is energized, set the output to 1 so the NO contacts close; otherwise set it to 0 [#21664111] The relay in this thread is connected to PIC16F887 PORT RA3 through a switching transistor, so the PIC output must control that transistor [#21664113] A complete C example was not given, and the exact code depends on the C compiler and how the relay is being commanded, so more details are needed [#21664115] The suggested approach is to define the schematic first, then a flow chart and algorithm before writing the PIC code [#21664116]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT
  • #1 21664110
    Pitso Mosoeu
    Anonymous  
  • ADVERTISEMENT
  • #2 21664111
    Earl Albin
    Anonymous  
  • ADVERTISEMENT
  • #3 21664112
    Muazu Musa
    Anonymous  
  • #4 21664113
    Pitso Mosoeu
    Anonymous  
  • #5 21664114
    Pitso Mosoeu
    Anonymous  
  • Clarifying relay control requirements and compiler choice

    #6 21664115
    Steve Lawson
    Anonymous  
  • ADVERTISEMENT
  • Recommend starting with schematics, flowcharts, and PIC Basic

    #7 21664116
    Mark Harrington
    Anonymous  
  • #8 21664117
    Mark Harrington
    Anonymous  
  • Amicus18 and Proteus development tools recommended

    #9 21664118
    Mark Harrington
    Anonymous  
  • ADVERTISEMENT
  • #10 21664119
    Earl Albin
    Anonymous  
  • #11 21664120
    Mark Harrington
    Anonymous  

Topic summary

LABEL_AI_GENERATED
The discussion focuses on developing a C program to control an ON/OFF relay using a PIC microcontroller, specifically energizing the relay coil at initialization to close normally open (NO) contacts. The relay is connected via a switching transistor to PORT RA3 of a PIC16F887. Key considerations include understanding the relay coil energization logic through conditional statements (IF, THEN, ELSE) and clarifying the communication method with the PIC. Recommendations emphasize starting with circuit schematics, flowcharts, and algorithm design before coding, suggesting assembler or PIC Basic for foundational learning. Useful resources and tools mentioned include MikroC Pro compiler, Amicus18 IDE, Crownhill development boards for PIC18 series, and Proteus Professional for simulation and PCB design. The approach advocates disciplined engineering practices, combining hardware design with software development and presentation skills.
AI summary based on the discussion. May contain errors.
ADVERTISEMENT