From d9d92203ea349d5eb44c0edc5565d827322caabe Mon Sep 17 00:00:00 2001 From: Jorawar Singh Date: Sun, 16 Jul 2017 22:17:43 +0530 Subject: Toolbox merge, RPI demos and structured demos --- macros/Hardware/RasberryPi/pwm/RPI_pwmClock.sci | 40 +++++++++++++++++++ macros/Hardware/RasberryPi/pwm/RPI_pwmMode.sci | 46 ++++++++++++++++++++++ macros/Hardware/RasberryPi/pwm/RPI_pwmRange.sci | 40 +++++++++++++++++++ .../Hardware/RasberryPi/pwm/RPI_pwmToneWrite.sci | 41 +++++++++++++++++++ macros/Hardware/RasberryPi/pwm/RPI_pwmWrite.sci | 45 +++++++++++++++++++++ macros/Hardware/RasberryPi/pwm/buildmacros.sce | 14 +++++++ macros/Hardware/RasberryPi/pwm/names | 5 +++ 7 files changed, 231 insertions(+) create mode 100755 macros/Hardware/RasberryPi/pwm/RPI_pwmClock.sci create mode 100755 macros/Hardware/RasberryPi/pwm/RPI_pwmMode.sci create mode 100755 macros/Hardware/RasberryPi/pwm/RPI_pwmRange.sci create mode 100755 macros/Hardware/RasberryPi/pwm/RPI_pwmToneWrite.sci create mode 100755 macros/Hardware/RasberryPi/pwm/RPI_pwmWrite.sci create mode 100755 macros/Hardware/RasberryPi/pwm/buildmacros.sce create mode 100755 macros/Hardware/RasberryPi/pwm/names (limited to 'macros/Hardware/RasberryPi/pwm') diff --git a/macros/Hardware/RasberryPi/pwm/RPI_pwmClock.sci b/macros/Hardware/RasberryPi/pwm/RPI_pwmClock.sci new file mode 100755 index 0000000..d065353 --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/RPI_pwmClock.sci @@ -0,0 +1,40 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function RPI_pwmClock(value) +// Function to set the divisor for the PWM clock. +// +// Calling Sequence +// RPI_pwmClock(value) +// +// Parameters +// value: The divisor for the PWM clock. +// +// Description +// This function sets the divisor for the PWM clock. +// +// Examples +// RPI_pwmClock(100) +// See also +// RPI_pwmMode, RPI_pwmRange, RPI_pwmToneWrite, RPI_pwmWrite +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pwC#1#"+string(value)+"#"; + if getos=="Linux" then + unix_w("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos=="Windows" then + RPI_winR=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction diff --git a/macros/Hardware/RasberryPi/pwm/RPI_pwmMode.sci b/macros/Hardware/RasberryPi/pwm/RPI_pwmMode.sci new file mode 100755 index 0000000..13d0c36 --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/RPI_pwmMode.sci @@ -0,0 +1,46 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function RPI_pwmMode(Mode) +// Function to set the mode for the PWM generator +// +// Calling Sequence +// RPI_pwmMode(mode) +// +// Parameters +// mode: The mode to set for the PWM generator. 'ms' (for mark:space) or 'bal' (for balanced) +// +// Description +// This function sets the mode for the PWM generator. The PWM generator can run in 2 modes – “balanced” and “mark:space”. The mark:space mode is traditional, however the default mode in the Pi is “balanced”. Switch modes by supplying the parameter: bal or ms +// +// Examples +// RPI_pwmMode('bal') +// See also +// RPI_pwmRange, RPI_pwmClock, RPI_pwmToneWrite, RPI_pwmWrite +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + if Mode=='ms' then + commande="pwM#1#0#"; + elseif Mode=='bal' then + commande="pwM#1#1#"; + else: + error("mode should be ""ms"" or ""bal"""); + end + if getos=="Linux" then + unix_w("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos=="Windows" then + RPI_winR=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction diff --git a/macros/Hardware/RasberryPi/pwm/RPI_pwmRange.sci b/macros/Hardware/RasberryPi/pwm/RPI_pwmRange.sci new file mode 100755 index 0000000..6a1503a --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/RPI_pwmRange.sci @@ -0,0 +1,40 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function RPI_pwmRange(value) +// Function to set the divisor for the PWM clock. +// +// Calling Sequence +// RPI_pwmRange(value) +// +// Parameters +// value: maximum of the range for the PWM generator. +// +// Description +// This function sets the range register in the PWM generator. The default is 1024. +// +// Examples +// RPI_pwmRange(512) +// See also +// RPI_pwmMode, RPI_pwmClock, RPI_pwmToneWrite, RPI_pwmWrite +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pwR#1#"+string(value)+"#"; + if getos=="Linux" then + unix_w("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos=="Windows" then + RPI_winR=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction diff --git a/macros/Hardware/RasberryPi/pwm/RPI_pwmToneWrite.sci b/macros/Hardware/RasberryPi/pwm/RPI_pwmToneWrite.sci new file mode 100755 index 0000000..d7ff6ed --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/RPI_pwmToneWrite.sci @@ -0,0 +1,41 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function RPI_pwmToneWrite(pin,freq) +// Function to write a tone of a given frequency to the pin +// +// Calling Sequence +// RPI_pwmToneWrite(pin,freq) +// +// Parameters +// pin : The pin to set the frequency on. Numbering to be followed as initiated using RPI_pinNumbering. +// freq: frequency to write +// +// Description +// This function write the given frequency tone to the given pin. +// +// Examples +// RPI_pwmToneWrite(0,100) +// See also +// RPI_pwmMode, RPI_pwmRange, RPI_pwmClock, RPI_pwmWrite, PRI_pinNumbering +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + commande="pwT#2#"+string(pin)+"#"+string(freq)+"#"; + if getos=="Linux" then + unix_w("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos=="Windows" then + RPI_winR=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction diff --git a/macros/Hardware/RasberryPi/pwm/RPI_pwmWrite.sci b/macros/Hardware/RasberryPi/pwm/RPI_pwmWrite.sci new file mode 100755 index 0000000..113547a --- /dev/null +++ b/macros/Hardware/RasberryPi/pwm/RPI_pwmWrite.sci @@ -0,0 +1,45 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function RPI_pwmWrite(pin,value) +// Function to write voltage value to the PWM register for the given pin. +// +// Calling Sequence +// RPI_pwmWrite(pin,value) +// +// Parameters +// pin : The pin number set the voltage at. Numbering sequence to be followed as initiated using RPI_pinNumbering function. +// value: The voltage to set at the given pin. Range is 0-1024. +// +// Description +// Writes the value to the PWM register for the given pin. The Raspberry Pi has one on-board PWM pin, pin 1 (BMC_GPIO 18, Phys 12). Other PWM devices may have other PWM ranges. +// +// Examples +// RPI_pwmWrite(1,500) +// See also +// RPI_pwmMode, RPI_pwmRange, RPI_pwmClock, RPI_pwmToneWrite +// +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + if [0