![]() ![]() Note we are using physical pin 9 as the ground and physical pin 11 as the power pin. For this example, we will be playing with the following circuit again. Hence, the Raspberry Pi can only simulate analog voltages between 0 and 3.3 volts. Note on the Raspberry Pi, the output voltage is 3.3 volts as opposed to the 5 volt output on the Arduino. (Note that the Period of a signal = 1/frequency, and frequency = 1/Period) So, it would be high 5 milliseconds, and low 5 milliseconds for a total period of 10 milliseconds, which as we expect, if a frequency of 100 Hz. If it had a duty cycle of 50% it would be high 50% of the time (.5X10 milliseconds= 5 milliseconds) and low 50% of the time (.5X10 milliseconds = 5 milliseconds). If the signal had a duty cycle of 100%, it would be “High” 100% of the time, and “Low” 0% of the time. the signal repeats itself every 10 milliseconds. This signal would have a Period of 10 milliseconds. Consider a signal with a frequency of 100 Hz. However, the implementation requires you to think in terms of a signal with a frequency and a duty cycle. This capability is also available on the Raspberry Pi GPIO pins. Arduino made it easy and transparent to the user to generate these analog-like output voltages using the analogWrite command. For many applications, such as controlling LED brightness, this approach works very well. Similarly, if you wanted to simulate a 1 volt analog out, you would time things so that the 5 volt signal was on 20% of the time. Hence, if you want to simulate a 2.5 volt signal, you could turn the pin on and off every quickly, timing things such that the pin was on half the time and off half the time. The truth is, though, we were not really writing analog voltages, we were just simulating analog voltages using pulse width modulation (PWM). If you remember our Arduino Lessons, you will recall that we could write analog voltages to the output pins with the ~ beside them.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |