Go Down

Topic: [RPI ?] Wiringpi, Bash, and PWM (Read 3717 times) previous topic - next topic

dritchie

Sep 09, 2014, 03:45 am Last Edit: Sep 09, 2014, 04:46 pm by dritchie Reason: 1
Greetings,
    Please hold your tomatos! But I was wondering if you guys could help me get a PWM type operation on my RPI, using Bash and wiringpi? I got a model A RPI as a bonus with a local PC trade. So for the last few days I've been trying to learn it's in and outs. I found, even though it has headers, it's nothing like an Arduino! :D Nonetheless, it's pretty sweet, mostly because it lets me do Bash!

   So I got it setup, or to the best of my knowledge. I got it running bash.sh scripts over ssh, writing digital 1's and 0's to LEDS. But then I made heatsinks, and I added a fan from an old laptop. I want this fan to adjust to the CPU temp, right now it's just on/off.

    I've been searching and searching for some PWM examples in Bash and I can't seem to find anything besides the declarations. Perhaps they don't exist. Currently I have a a transistor hooked up to the GPIO 18 pin, which I believe is the only hardware pin, out of the box.

This is not code I'm using, but kind of a representation where I'm at with PWM.
#!/bin/bash

gpio mode pwm 1 #wiringpi's 1, is 18.

fadeAmnt=0
while [ 1 = 1 ]; do
    fadeAmnt=$((fadeAmnt+10))
    gpio pwm 1 $fadeAmnt

if [ $fadeAmnt = 1024 ]; then
    exit
fi
done

   

PaulS

Quote
Please hold your tomatos!

Why? Your question has NOTHING to do with the Arduino. There IS a pi forum. Go ask there!
The art of getting good answers lies in asking good questions.

nickgammon

Quote
This is not code I'm using, ...


Not the code, eh?

Quote
I found, even though it has headers, it's nothing like an Arduino!


Yes, then this is the wrong forum, sorry. May as well ask about a Chevrolet on a Ford forum.




Did Google massively misfire?
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

dritchie

#3
Sep 09, 2014, 04:44 pm Last Edit: Sep 09, 2014, 04:48 pm by dritchie Reason: 1

Quote
This is not code I'm using, ...


Not the code, eh?

Quote
I found, even though it has headers, it's nothing like an Arduino!


Yes, then this is the wrong forum, sorry. May as well ask about a Chevrolet on a Ford forum.




Did Google massively misfire?


Yes, that is not the code I'm using because as it stands, it doesn't work. It'll compile, so to speak, but I don't see any results from the header.

But your blind if you don't think the two devices has anything in common. Your also closed minded to think no one on this forums has dealt with them. Honestly, I thought this was going to be a newb, 1 second solution. Don't respond with wrong forum, only because you don't have any other constructive input. (I asked there as well.) Keep poking, I respect you as a knowledgeable member here, but know, I don't care to hear it.

PaulS

Quote
but know, I don't care to hear it.

I don't like to hear it when I'm wrong, either. But no one cuts me any slack, so why should we cut you any? Your question is in the wrong place and not deserving of an answer HERE.
The art of getting good answers lies in asking good questions.

dritchie


Quote
but know, I don't care to hear it.

I don't like to hear it when I'm wrong, either. But no one cuts me any slack, so why should we cut you any? Your question is in the wrong place and not deserving of an answer HERE.


That's ok. XD

For those who stumble across this via google. I couldn't get PWM to work on the fan using a transistor @ 5v. However, I did get it to work with a normal LED. Appearently, you need more equipment to process the PWM signal. I don't know.

Range: 0-1023

Declaration:
gpio mode <pin> pwm

To write:
gpio pwm 1 <value>

PaulS

Quote
Appearently, you need more equipment to process the PWM signal. I don't know.

Clearly. Since you posted no wiring diagram to show how you connected the transistor, all we can do is assume that you didn't connect it properly.

The PWM pin has no idea what it connected to it. It turns the pin on and off at the appropriate times, with the appropriate duty cycle, regardless of what is connected to it - LED, transistor, rutabaga, or nothing.
The art of getting good answers lies in asking good questions.

dritchie


Quote
Appearently, you need more equipment to process the PWM signal. I don't know.

Clearly. Since you posted no wiring diagram to show how you connected the transistor, all we can do is assume that you didn't connect it properly.

The PWM pin has no idea what it connected to it. It turns the pin on and off at the appropriate times, with the appropriate duty cycle, regardless of what is connected to it - LED, transistor, rutabaga, or nothing.


Sorry. I didn't know there were multiple ways to connect a transistor.

The transistor is between the negative lead of the fan. The center pin of the transistor is  connect to pin 18 of the pi. There is a capacitor between the fans + & - lead, for it to have enough power to kick on and not draw to much from the device.

The fan won't kick on with 3.3v. Which is the rating I get with my multimeter from the PWM signal set at 1023. It will with direct 5v.

UKHeliBob

Quote
Sorry. I didn't know there were multiple ways to connect a transistor
Not only that, there are multiple types of transistor.
Quote
The transistor is between the negative lead of the fan.
Between the negative lead of the fan and where ?
Quote
The center pin of the transistor is  connect to pin 18 of the pi
That pin does what exactly on the Pi ?
Quote
There is a capacitor between the fans + & - lead,
What type/value of capacitor ?
Quote
to have enough power to kick on and not draw to much from the device.
This is surely nonsense.
Quote
The fan won't kick on with 3.3v. Which is the rating I get with my multimeter from the PWM signal set at 1023. It will with direct 5v.
Do you understand that a PWM output does not provide a steady voltage ?  Rather it provides a fixed voltage that turns on and off, ie is Modulated, with a variable duty cycle depending on the Width of the Pulse
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

nickgammon

This is nothing to do with Programming Questions on the Arduino.

I'm moving it to Bar Sport.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

dritchie


Quote
Sorry. I didn't know there were multiple ways to connect a transistor
Not only that, there are multiple types of transistor.
Quote
The transistor is between the negative lead of the fan.
Between the negative lead of the fan and where ?
Quote
The center pin of the transistor is  connect to pin 18 of the pi
That pin does what exactly on the Pi ?
Quote
There is a capacitor between the fans + & - lead,
What type/value of capacitor ?
Quote
to have enough power to kick on and not draw to much from the device.
This is surely nonsense.
Quote
The fan won't kick on with 3.3v. Which is the rating I get with my multimeter from the PWM signal set at 1023. It will with direct 5v.
Do you understand that a PWM output does not provide a steady voltage ?  Rather it provides a fixed voltage that turns on and off, ie is Modulated, with a variable duty cycle depending on the Width of the Pulse


Pin 18 on the pi is the only pin the supports PWM, out of the box. I believe they have other hardware and software solutions for more.

Anywho, it was a long shot. I need to make a standalone component to supply proper external power to the fan. That way I can get rid of the transistor and  adjust the voltage directly by reading the tachometer (Yellow line). Which sounds easier said than done, being I don't have a scope. Anyway, thanks for your input.

Henry_Best


Quote
This is not code I'm using, ...


Not the code, eh?

Quote
I found, even though it has headers, it's nothing like an Arduino!


Yes, then this is the wrong forum, sorry. May as well ask about a Chevrolet on a Ford forum.




Did Google massively misfire?

I'm wondering if he goes to a plumber for medical advice...

Go Up