Sponsored Content
Full Discussion: PWM script for raspbian
Top Forums Shell Programming and Scripting PWM script for raspbian Post 302910611 by drux on Friday 25th of July 2014 06:46:09 PM
Old 07-25-2014
PWM script for raspbian

Hello Community,

I'm a little new to shell scripting and i was trying to write a servo control script for my Raspberry PI, using raspbian.

here is the code.

Code:
#!/bin/sh
#Signal time
signal_time_gpio27=0.0015s
#Delay time
signal_delay_gpio27=0.02s


if 
grep -lq 0 /sys/class/gpio/gpio27/value 
then
echo 1 >/sys/class/gpio/gpio27/value | 2>/dev/null
while true
do
sleep $signal_time_gpio27
echo 0 >/sys/class/gpio/gpio27/value | 2>/dev/null
sleep $signal_delay_gpio27
echo 1 >/sys/class/gpio/gpio27/value
done
else
echo 0 >/sys/class/gpio/gpio27/value | 2>/dev/null
echo "ERROR! Output is 1 - reset to 0"
echo "Current output:"
cat /sys/class/gpio/gpio27/value
fi

Unfortunately the servo does not move..

teach me masters


regards,

drux
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

2. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

[bash] Zenity loop (raspbian)

Hello folks, I have created a GUI but i face some issue with the loop either i am stuck in the loop or it close the program In the code below it work fine for the "go to menu" if i press cancel i go back to the main menu but for "test" i m stuck in the menu Appreciate some help :/... (13 Replies)
Discussion started by: flammeur
13 Replies

5. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

6. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies
GPIO(4) 						   BSD Kernel Interfaces Manual 						   GPIO(4)

NAME
gpio -- General Purpose Input/Output SYNOPSIS
gpio* at elansc? gpio* at epgpio? gpio* at gcscpcib? gpio* at gpiosim? gpio* at gscpcib? gpio* at ichlpcib? gpio* at nsclpcsio? gpio* at ppbus? #include <sys/types.h> #include <sys/gpio.h> #include <sys/ioctl.h> DESCRIPTION
The gpio device attaches to the GPIO controller and provides a uniform programming interface to its pins. Each GPIO controller with an attached gpio device has an associated device file under the /dev directory, e.g. /dev/gpio0. Access from user- land is performed through ioctl(2) calls on these devices. Whether the layout of the GPIO device can be configured is subject to authorization by the kauth(9) framework. If for example secmodel_securelevel(9) is active, the layout of the GPIO device is defined at a securelevel less than 1, i.e. typically dur- ing system boot, and cannot be changed later. GPIO pins can be configured and given a symbolic name and device drivers that use GPIO pins can be attached to the gpio device at a securelevel less than 1. All other pins will not be accessible once the runlevel has been raised. IOCTL INTERFACE
The following structures and constants are defined in the <sys/gpio.h> header file: GPIOINFO (struct gpio_info) Returns information about the GPIO controller in the gpio_info structure: struct gpio_info { int gpio_npins; /* total number of pins available */ }; GPIOREAD (struct gpio_req) Returns the input pin value in the gpio_pin_op structure: #define GPIOMAXNAME 64 struct gpio_req { char gp_name[GPIOMAXNAME]; /* pin name */ int gp_pin; /* pin number */ int gp_value; /* value */ }; The gp_name or gp_pin field must be set before calling. GPIOWRITE (struct gpio_req) Writes the output value to the pin. The value set in the gp_value field must be either GPIO_PIN_LOW (logical 0) or GPIO_PIN_HIGH (log- ical 1). On return, the gp_value field contains the old pin state. GPIOTOGGLE (struct gpio_req) Toggles the pin output value, i.e. changes it to the opposite. gp_value field is ignored and on return contains the old pin state. GPIOSET (struct gpio_set) Changes pin configuration flags with the new ones provided in the gpio_set structure: #define GPIOMAXNAME 64 struct gpio_set { char gp_name[GPIOMAXNAME]; /* pin name */ int gp_pin; /* pin number */ int gp_caps; /* pin capabilities (ro) */ int gp_flags; /* pin configuration flags */ char gp_name2[GPIOMAXNAME]; /* new name */ }; The gp_flags field is a combination of the following flags: GPIO_PIN_INPUT input direction GPIO_PIN_OUTPUT output direction GPIO_PIN_INOUT bi-directional GPIO_PIN_OPENDRAIN open-drain output GPIO_PIN_PUSHPULL push-pull output GPIO_PIN_TRISTATE output disabled GPIO_PIN_PULLUP internal pull-up enabled GPIO_PIN_PULLDOWN internal pull-down enabled GPIO_PIN_INVIN invert input GPIO_PIN_INVOUT invert output GPIO_PIN_PULSATE pulsate output Note that the GPIO controller may not support all of these flags. On return the gp_caps field contains flags that are supported. If no flags are specified, the pin configuration stays unchanged. Only GPIO pins that have been set using GPIOSET will be accessible at securelevels greater than 0. GPIOUNSET (struct gpio_set) Unset the specified pin, i.e. clear its name and make it unaccessible at securelevels greater than 0. GPIOATTACH (struct gpio_attach) Attach the device described in the gpio_attach structure on this gpio device. struct gpio_attach { char ga_dvname[16]; /* device name */ int ga_offset; /* pin number */ uint32_t ga_mask; /* binary mask */ uint32_t ga_flags; /* driver dependent */ }; The drvctl(8) command can be used to detach a device from a gpio pin. FILES
/dev/gpiou GPIO device unit u file. SEE ALSO
ioctl(2), drvctl(8), gpioctl(8) HISTORY
The gpio device first appeared in OpenBSD 3.6 and NetBSD 4.0. AUTHORS
The gpio driver was written by Alexander Yurchenko <grange@openbsd.org>. gpio and was ported to NetBSD by Jared D. McNeill <jmcneill@NetBSD.org>. Runtime device attachment was added by Marc Balmer <marc@msys.ch>. BUGS
Event capabilities are not supported. BSD
November 13, 2011 BSD
All times are GMT -4. The time now is 04:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy