I2C. V.S. PWM

494 views
Skip to first unread message

Brian Higgins

unread,
May 23, 2021, 5:38:04 PM5/23/21
to hbrob...@googlegroups.com
What is the difference between I2C. And PWM? I’m using a piezo speaker, lily pad vibrating pad and a ultrasound sensor. Switching to I2C you need a capacitor and a extra board. You just doubled the foot print of the sensor package.

Brian

Sent from my iPhone XX

Chris Albertson

unread,
May 23, 2021, 5:52:42 PM5/23/21
to hbrob...@googlegroups.com
I2c is a kind of serial data.   You can send any kind of information over it, commands, sensor data, and so on.

With PWM you are sending just one number.   PWM is very much like an analog voltage in a wire.

You might use PWM to control the speed of one motor or the brightness of one LED but you could use I2C to send the readout of an IMU that contains quite a lot of complex data values.

--
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/B08EC2C2-B974-4578-85AB-379D4A7F8731%40gmail.com.


--

Chris Albertson
Redondo Beach, California

Sergei Grichine

unread,
May 23, 2021, 6:14:21 PM5/23/21
to hbrob...@googlegroups.com
By switching to PWM you just tripled your wiring ;-)

Best Regards, 
-- Sergei Grichine 

Mark Johnston

unread,
May 23, 2021, 6:19:47 PM5/23/21
to hbrob...@googlegroups.com
In the context of creating sound I think you may be thinking I2S  which is a serial protocol that you then get a decoder chip or small board from Adafruit.  The I2S driver on lets say a raspberry Pi creates the I2S serial signal that can transmit stereo and then your little I2S board which usually also has a small speaker amp on it converts to signals suitable for the speaker(s).    

PWM in the context of driving a speaker is where like Chris says the 'Pulse Width Modulated' signal has it's duty cycle dynamically modulated so that at the far end given a device like a speaker and perhaps some capacitance ends up with a signal low enough in frequency to be averaged out into an analog signal for the speaker.    

We here in 'robot land'  often drive motors with PWM and use the duty cycle of the PWM signal to control the speed of the motor (or more accurately the power the motor can use to run).     You asked about sound so we don't have to discuss motor control with PWM but it is extremely popular for driving motors for robot wheels, even 3-phase brushless motors.

Mark Johnston

unread,
May 23, 2021, 6:21:59 PM5/23/21
to hbrob...@googlegroups.com
To learn more about I2S see the all in one Adafruit board which describes it nicely.  https://www.adafruit.com/product/3006

Brain Higgins

unread,
May 23, 2021, 8:00:16 PM5/23/21
to hbrob...@googlegroups.com
I’m didn’t include all of the information sorry. I have a Lidar lite V3 on one end of the Arduino controller board which drives sound and vibration from the Lidar data as it detects objects.  They have  now added two ultrasonic sensors and have moved to what looked like I2C I guess it could be I2S.  My clue is all the sensors are attached to a board and not directly hook to the micro controller board.  And the capacitor attached to the board.  I was trying to create the smallest footprint as possible. My first prototype ran straight off of the Arduino controller board with only the Lidar providing data to a piezo and lily pad
Brian 

Sent from my iPhone XX

On May 23, 2021, at 6:22 PM, Mark Johnston <mjst...@gmail.com> wrote:



Rafael Skodlar

unread,
May 24, 2021, 2:07:41 AM5/24/21
to hbrob...@googlegroups.com
I'm sure it's I2C. Here is what Wikipedia says about it:
"I²C, pronounced I-squared-C, is a synchronous, multi-master, multi-slave, packet switched, single-ended, serial communication bus invented in 1982 by Philips Semiconductor". It's used in microcontroller based circuits because it needs only 4 wires to communicate between major components. Each component on the I2C bus needs to have a unique address.
A multiplexer is needed if you need more than 8 devices to exchange data.
Best place to learn about this bus is https://www.i2c-bus.org/

Rafael




--
--
Rafael

Mark Johnston

unread,
May 24, 2021, 5:25:44 AM5/24/21
to HomeBrew Robotics Club
Sensors are always talked to with I2C, not I2S,  and I do a TON of that.  Because you were discussing audio interfacing is why I asked if you were really interested in a pure audio interface and thus I2S.   Both exist, both are popular, I have used both.    It was just asking if you 'meant' I2S for an audio interface.
You can talk to many sensors with SPI and 'sometimes'  standard serial too but that has not been mentioned yet.


Reply all
Reply to author
Forward
0 new messages