element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Embedded Forum STM32L4 With DMX512
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 31 replies
  • Answers 11 answers
  • Subscribers 464 subscribers
  • Views 9258 views
  • Users 0 members are here
  • dmx512
  • stm32l4
Related

STM32L4 With DMX512

p.congre
p.congre over 3 years ago

Hello there,

 

I am trying to control 2 LED strips (one with a WS2811 LED driver and one with a USC512C4 LED driver) with my STM32L4 with integrated RS485.

Do you have any idea how to do this?

 

Best regard.

P.Congré

  • Sign in to reply
  • Cancel

Top Replies

  • michaelkellett
    michaelkellett over 3 years ago in reply to p.congre +1 suggested
    In xxx_project.h, #ifndef __C459_PROJECT_H #define __C459_PROJECT_H // INCLUDES #include "stm32f0xx.h" #include <stdio.h> #include <stdbool.h> #include <stdint.h> // DEFINES #define VERSION 100 #define…
  • p.congre
    0 p.congre over 3 years ago in reply to jc2048

    I already tried to contact ST, but nothing for the moment.

     

    I can't use arduino because the next step of the project is to control the LED strip with an STM32.

     

    best regard.

     

    P.Congré

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • jc2048
    0 jc2048 over 3 years ago in reply to p.congre

    If you don't mind a hardware engineer telling you how to deal with debugging, here's how I'd tackle it:

     

    Does anything at all emerge from the STM32? Can you see any sign of serial waveforms at the output pin, even if it just sends a frame of 513 characters and then freezes at the break?

     

    Is your 485 chip matched to the IO voltage standard of the processor? [Not all of the older ones would be ok on 3.3V]

     

    What can you see on the A and B outputs of the driver chip?

     

    Have you wired the outputs the right way round to the LED strip?

     

    If you see a lot of overshoot and the sigals are very messy, look carefully at how you've done the termination on the RS-485. [The strip might be much more fussy than a normal DMX receiver.]

     

    If there's still nothing, try hacking together a bit of very simple test code to repetitively send a serial character and look again.

     

    If that works, go back to the DMX code and disable the stuff that does the break [the fiddly stuff with a timer that could esily go wrong] and verify that it's sending the character stream ok, then start working on the break code, maybe even isolating it and just repetitively sending the break until you get the timing right.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • p.congre
    0 p.congre over 3 years ago in reply to jc2048

    I can see the waveform of my TX PIN when I send 513 times a "U".

    The 485 chip matches the IO voltage, I checked it and I can also see the waveform of the A and B output.

    I double checked the cable connection for the LED strip.

    I know it's not hardware but rather software, I couldn't create a correct code to control the LEDs.

     

    Best regard.

     

    P.Congré

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 3 years ago in reply to p.congre

    ^ Great debugging tips from Jon.

    Right now I'm trying to get hardware and software working. I did not create the hardware nor the software, but I won't raise a case until I've:

    1. Verified connections and voltages

    2. Connected a 'scope or attached a logic analyzer (they cost less than $20) and examined if the interface signals are what I expect

    3.  Grabbed debug from the code

    4.  Tried different hardware and software combinations to try to narrow down the problem

    5. Sketch a diagram or take photos or video to show precisely what I'm doing

    6.  Supply any configurations or log file content

     

    For your scenario, maybe point 2 and 4 are also relevant, since you could compare the working scenario (Arduino) with the non-working scenario, and compare the signals, to see what the difference is.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • genebren
    0 genebren over 3 years ago in reply to p.congre

    Here are a couple of things to check:

     

    1. Is the serial port setup correctly?  It should be baudrate of 250,000, 8 data bits and 2 stopbits.
    2. Is the Break pulse correct? The Break pulse needs to be at least 80uS, preferably larger (the specs are not always followed).  This pulse should be a low going pulse.
    3. Is the post Break correct?  The Post break needs to be at least 12uS, preferably larger (again the spec is not always followed).
    4. Is the Start Code (first byte of the DMX stream) correct?  Some devices need this byte to be a zero, others may have other special requirements.

     

    Good luck!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • jc2048
    0 jc2048 over 3 years ago in reply to p.congre

    That's good. You're not far off a working system.

     

    Do you see the break, after the frame of data is sent, present in the DMX waveform?

     

    I've never used the devices on the LED strip, but they probably depend on the subsequent break as part of their operation.

     

    It's also part of the DMX spec that you have to keep sending the break and the frame repetitively. I don't think the spec says what the receiver should do if the DMX disappears, but I think it implies the designer of the receiver should do something for what is then considered to be a fault condition if it disappears for more than a second or two [for a lamp in a theatre setting, the normal thing would be for it to shut down on loss of DMX to stop it interferring with the rest of a lighting rig].

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • p.congre
    0 p.congre over 3 years ago in reply to shabaz

    The problem is that I don't really know what line to follow to create the code, I know I need to set up a uart communication with 250000 bauderate.

     

     

    I know the DMX protocol but I don't know how to implement it in my stm32.

    image

     

    The code for the arduino is an example that I modified to create different animations.

     

    best regard.

     

    P.Congré

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • genebren
    0 genebren over 3 years ago in reply to p.congre

    Paul,

     

    I do not have much (if any) experience with STM32, but I did find this code that might help you along:

    https://github.com/carl3721/stm32-dmx512/blob/master/dmx-p103/src/main.c

     

    It was an easy search of "stm32 dmx example", which seem to have lots of results.

     

    I take from all of this that is very new to you.  I have found that Google is your friend, and you will likely find lots of help there (and here).  You really need to break it down into little pieces when you are looking for help.  DMX has been around for quite a while, but there are not many examples, as a lot of people are buying solutions from a small handful of suppliers, that wrap all of the messy stuff up into libraries or standalone hardware.

     

    Gene

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • p.congre
    0 p.congre over 3 years ago in reply to genebren

    Hello Gene,

     

    I've already tried this git repository, it's only used to receive data, I'm trying to send data to the control light.

     

    Best regard.

     

    P.Congré

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelkellett
    0 michaelkellett over 3 years ago in reply to p.congre

    The two links to code that you posted are both code bases for STM32F10x processors - you are using an STM32L4xxx which will be different.

    I can't guess all the things (if any) which will be wrong without:

     

    1) Your code

    2) A schematic or detailed block diagram of your set up

    3) A pin list showing which processor pins are used for what

     

    It would also help if you told us what software and debugging tools you are using (including do you have a scope or logic analyser).

    Pictures often help as well.

     

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube