MCU choice, Comm's protocol help & EMI challenges!

Thread Starter

cminke

Joined Jun 7, 2014
41
Hello,
i need help with the following topics
Choosing a microcontroller
Choosing a comms protocol
Reducing EMI, issues with an onboard audio amp

MCU
I am slightly experienced in Arduino mega 2560 so that would be familiar,
I'm learning PIC and would be open to options from there.

I have a need of :
1 USB
2 ch audio out.
10 inputs that detect change (0v to 12V+ or 12V+ down to 0v)
18 Outputs to use with a MOSFET bank (switching 12v/10A outputs)
10 Outputs with parallel/ daisy-chainable comms that can output each output to 32 addressable slave units, each with their own microcontroller.

which leads to my next question.

COMMS
what comms can I send down the line, to tell each unit, you are "[recive data] > [do this] > [send remaining] "
[Master]>[slave]>[slave]>[slave]>[slave]>[slave]>[slave]>[slave] end
I have 6 wires available, 2 dedicated 12v+, GND and 4 remaining for data and clk.


EMI
I'm trying to reduce the amount of EMI produced because this equipment will be in close proximity to sensitive radio equipment
and will have its own audio amp built into it.
 

Thread Starter

cminke

Joined Jun 7, 2014
41
the run length is about 50Ft max, my understanding is that I2C is not ideal for long travel runs more then like a couple CMs. I may use RS485, ill have to look into it. any limitations?
 

JohnInTX

Joined Jun 26, 2012
3,947
I don't know about the PIC18F85K22, I don't think it has USB and it's a chip with built-in LCD drivers. If you're not using LCD, there's probably a better one. But avoid the 16F877A - it's a very dated midrange device, not recommended for new designs. Compared to the 18Fxxx and 16F1xxx parts, midrange (16Fxxx parts) is a dead end and not worth the trouble.

I2C is good maybe for a couple of meters before you have to start dealing with electrical issues - noise, cable capacitance etc. It's nice in that the standard is very well specified and things like slave addressing etc. is built in. You still have to pay attention to error handling etc.

RS-485 is a good choice for medium haul runs in a noisy environment and supports multi-drop applications seamlessly. But it is just a physical layer, you have to implement your own protocol to sort out how slaves respond to the master, addressing, error handling etc. The PIC USART is used as the serial interface, preferably with interrupt-driven buffers to mitigate the lack of flow control. You use an RS-485 driver to generate the balanced signals for the bus. RS-485 is more suited to one master, many slave applications. The 9th bit addressing feature of uCHIP's USART can be useful for the slaves to sort out which messages are for them. Take a look at Modbus for a typical protocol. @MaxHeadRoom is up on this stuff..

I'd take a look at the CAN bus. It uses a multi-drop balanced bus like RS-485 and has all of the protocols, error checking, addressing and everything else built right into the chip. Load up the data buffer and set the 'send' bit. The data gets to the slave accurately, guaranteed. The protocol will retry bad comms automatically and report errors. Slaves can send unsolicited data to the master if desired or wait for the master to poll them. CAN is 'message based' i.e. each message has an identifier that specifies what it is. Receivers apply filters that allow only the messages they're interested in so if something shows up in the RX buffer, it's for that slave. Examine the message ID to see who gets the data.

I've done lots of work using all of these and CAN is my favorite for master/slave or many point systems.

@danadak might have some ideas in some of that cool drag and drop stuff he uses..

Thanks, gentlemen.

Good luck and have fun!

EDIT: since RS-485 and CAN use balanced differential signalling, the EMI radiation and susceptibility will be less than I2c which is single-ended. Running the signals in a shielded twisted pair would be the snizzle.

Take a look at Curiosity HPC and the Mikro Click boards to maybe make your prototyping easier.
 
Last edited:

Thread Starter

cminke

Joined Jun 7, 2014
41
thank you :) ill remember that! lots of good info and yeah i was eyeing the CAN bus as a possible.

in the sense of cost, are there PIC or AVR chips that have built in can bus?

as i explained i need
ABDCE===== [send out to slaves]==== slaveA [receive A] [send BCDE]=====slaveB [receive B][send CDE]

as im understanding id need a dedicated canbus chip outside of the master and slave MCUs?
 

danadak

Joined Mar 10, 2018
3,793
1 USB
2 ch audio out.
10 inputs that detect change (0v to 12V+ or 12V+ down to 0v)
18 Outputs to use with a MOSFET bank (switching 12v/10A outputs)
10 Outputs with parallel/ daisy-chainable comms that can output each output to 32 addressable slave units, each with their own microcontroller.
1) The audio, is that processor generated or MP3 stream or ? PSOC has
DACs that can be used to generate audio.
2) PSOC has scanning comparator, or just use muxed SAR (mux and SAR and Vref internal
to PSOC)
3) I /O to ~ 80
4) Many choices SPI, CAN, UART, I2S, I2C...

Here is a representative example (has USB to Audio stream, scanning comparator, COMM, pins, LCD) -

upload_2019-10-10_16-11-59.png

All onchip, PSOC 5LP familiy. IDE and compiler free -

https://www.cypress.com/products/psoc-creator-integrated-design-environment-ide

Extensive library of projects, 100's, many training videos. Drag and drop components
onto canvas, wire them up (to internal and offchip). A component is an onchip resource.
Attached a catalog of components.

Additionally PSOC comunity has deisgn libraries of components that can be added
to tool for use, like DDS, 74HC like logic MSI, specialized PWM......


Regards, Dana.
 

Attachments

Thread Starter

cminke

Joined Jun 7, 2014
41
1) The audio, is that processor generated or MP3 stream or ? PSOC has
DACs that can be used to generate audio.

iw ill be whatever it needs to be, this is all ground up and I don't have any limits around audio format, source. it will likely be a stored file that will be amplified. but it would have to be as pure as possible. its only a single tone/ channel, nothing detailed.





Regards, Dana.
[/QUOTE]
 

danadak

Joined Mar 10, 2018
3,793
You could use the WAVEDAC in PSOC to generate the tones. What
harmonic suppression spec do you have ? What are the freqs of
the tones ?

1572539661790.png

Regards, Dana.
 
Top