Selflover wrote:Hey there!
So I just joined and found this post, and I've got to say: I'm VERY interested in giving this a shot!
The main thing I'm curious about though is how I can set up my inflatable plug so that it can be inflated electronically. You had mentioned that a 'step motor' could be used in order to inflate the plug. Do you have a guide I could go by on how I should go about setting this up? I'm totally new to electronics and working with step motors or Arduino boards for that matter, so any help (pictures or diagrams especially!) would be GREATLY appreciated!
Hello Selflover.
The best way of using a pump would be a valve operated by an Arduino an a relay (there was an user that posted that he did it).
I have created a pain.exe to interact with an Arduino just setting to HIGH or LOW a pin with a maximum amount of times to prevent overinflation.
You can get it here:
Inside the zipp you will find the pain.exe (the program that will inflate your pump),A .dll taht must be placed in the same folder where you want to execute your pain.exe, a .ino file with the sketch to upload to your Arduino:
Code: Select all
/* Sketch Name..: Pain.pde to turn pin 13 HIGH or LOW state due to COM port data recieved
* Author.......: Qwerty212
* Email......: qwertybcn121@gmail.com
* Description..: Turn a digital pin either on or off using an AutoIt program
* comunicating using a serial connection.
* Date Created.: 01/04/2013
*/
// Include Function Library
//#include
int val = 0; // a value accumulated from data on the serial port
int led = 13;//Put another numbr of pin if you need to change it
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
digitalWrite(led, LOW); // turn pin 13 to LOW before sart playing
}
void loop()
{
if ( Serial.available())
{
char ch = Serial.read();
if(ch >= '0' && ch <= '9'){ // is ch a number?
val = ch; // then val = to the recieved number
if(val = 0){// if the arduino get a 0 from the serial port
digitalWrite(led, HIGH); // turn pin 13 to HIGH
delay(50);
}
else if(val = 1) // if the arduino get a 1 from the serial port
{
digitalWrite(led, LOW); // turn pin 13 to low
delay(50);
}
}
}
}
and a .ini file to configure how your pain.exe will work:
Code: Select all
[Settings]
COM_Port=4
Time_Sleep=1000
Max_Punishment=10
Agreggated_Punishment=0
In the ini file just set the com port, the time that the pin will be set at hihg state, the maximum allowed punishment (to prevent overinflation of the plug) andthe actual agreggatted punishment (edit the ini file and set it to 0 every time you start a new session).
If you want to use a Stepper motor or a Servomotor to operate with your inflatable plug you just need to edit the Arduino sketch to react different to the data recieved via the serial port. (you are gong to need a servo with a huge torque)
Here you can also take a look at the source of the pain.exe:
Code: Select all
#include 'CommMG.au3'
#include <resources.au3>
#AutoIt3Wrapper_Icon=icon.ico
Global $File = @ScriptDir & "\Settings.ini"
If Not FileExists($File) Then
IniWrite(".\Settings.ini", "Settings", "COM_Port", "4")
IniWrite(".\Settings.ini", "Settings", "Time_Sleep", "1000")
IniWrite(".\Settings.ini", "Settings", "Max_Punishment", "0")
IniWrite(".\Settings.ini", "Settings", "Agreggated_Punishment", "0")
EndIf
;Internal for the Serial UDF
Global $sportSetError = ''
_CommSetDllPath(@ScriptDir & "\commg.dll");The dll must be i the same folder that the pain.exe
;COM Vars
Global $CMPort = IniRead(".\Settings.ini", "Settings", "COM_Port", "4");Read the ini file for the COM Port to be used, default is 4
Global $CmBoBaud = 9600 ; Baud
Global $CmboDataBits = 8 ; Data Bits
Global $CmBoParity = "none" ; Parity
Global $CmBoStop = 1 ; Stop
Global $setflow = 2 ; Flow
;Sleeping Time
Global $TimeSleep = IniRead(".\Settings.ini", "Settings", "Time_Sleep", "1000");Read the ini file for the time that the pin will be set at HIGH.
; REMEMBER Time in MILISECONDS!!!
;Max Times that you want to be punished
Global $MaxPunishment = IniRead(".\Settings.ini", "Settings", "Max_Punishment", "0");Read the ini file for the max number
;of punishment allowed (prevents overinflated pumps
; REMEMBER that 0 equals to INFINITE punishment
_CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow)
_CommSetRTS(0)
_CommSetDTR(0)
Global $AgreggatedPunishment = IniRead(".\Settings.ini", "Settings", "Agreggated_Punishment", "0");Read the ini file for the current
;number of punishment you have recived till the moment.
If $MaxPunishment <> 0 And $AgreggatedPunishment <= $MaxPunishment Then ;if you are playing with a maximun allowed punishment then...
Local $newAgreggatedPunishment = $AgreggatedPunishment + 1
IniWrite(".\Settings.ini", "Settings", "Agreggated_Punishment", "0");We write the new value of agreggated punishment in the .ini
Sleep(20)
_CommSendString("1");send data through Com port to set pin to HIGH
Sleep($TimeSleep);Sleep the required miliseconds
_CommSendString("0");send data through Com port to set pin to LOW
Sleep(20)
_CommCloseport()
Exit
EndIf
If $MaxPunishment = 0 Then ;if you are playing without a maximun allowed punishment then...
Sleep(20)
_CommSendString("1");send data through Com port to set pin to HIGH
Sleep($TimeSleep);Sleep the required miliseconds
_CommSendString("0");send data through Com port to set pin to LOW
Sleep(20)
_CommCloseport()
Exit
EndIf
If $MaxPunishment <> 0 And $AgreggatedPunishment > $MaxPunishment Then
_CommCloseport()
Exit
EndIf
Greets from Barcelona