Show Posts
Pages: [1] 2
1  Using Arduino / Motors, Mechanics, and Power / Arduino motor shield and 12 volt motor? on: May 09, 2013, 02:14:14 am
Hi I have a 12 volt motor that I need to spin the platter and record of an old gramophone. I'm just wondering would it be safe to use this with an arduino motor shield and an external power supply or would it blow the board. The shield says it supports up to 12 volts of power but Im wary to try powering the 12 volt motor in case something goes wrong. Would I be better off getting a slightly less powerful motor or try using a H-bridge setup? I'm kind of stuck for time to hand up this project and I don't want to waste time on working out how to use a h-bridge if I don't have to.
2  Using Arduino / Interfacing w/ Software on the Computer / Re: Processing to arduino serial question? on: April 20, 2013, 04:52:27 pm
Quote
The Arduino is not talking to PD and Processing, is it? It only has one serial port that is connected to the PC via the USB cable. It can only talk to one application on the PC end.
No I have Processing acting as a middleman of sorts to communicate between the two. PD is pulling data from processing and processing is using the processing serial to work with arduino.


Quote
I wouldn't understand the PD side, but seeing the Arduino code might provide some clues as to how to help you.
I have the PD side mostly finished but the arduino code I am using is based on a hardware debounce but I am now using an optical encoder for more stability and I have yet to rectify the code. I still must take out unnecessary attaches and detaches as well as using CHANGE instead of RISE and FALL.

The Arduino sketch:
Code:
int pulses, A_SIG=0, B_SIG=1;
int digitalInput5 = 5; 
int value5 = '0'; // switch setup to reset encoder values



void setup(){
  attachInterrupt(0, A_RISE, RISING);
  attachInterrupt(1, B_RISE, RISING);
  pinMode(digitalInput5,OUTPUT);

  Serial.begin(9600);
}//setup


void loop(){
  value5 = digitalRead(5);
   if (value5 ){
pulses=0; //pulses reset to zero
}
 
 
}

void A_RISE(){
 detachInterrupt(0);
 A_SIG=1;
 
 if(B_SIG==0)
 pulses++;//moving forward
 if(B_SIG==1)
 pulses--;//moving reverse
 Serial.println(pulses);
 attachInterrupt(0, A_FALL, FALLING);
}

void A_FALL(){
  detachInterrupt(0);
 A_SIG=0;
 
 if(B_SIG==1)
 pulses++;//moving forward
 if(B_SIG==0)
 pulses--;//moving reverse
 Serial.println(pulses);
 attachInterrupt(0, A_RISE, RISING); 
}

void B_RISE(){
 detachInterrupt(1);
 B_SIG=1;
 
 if(A_SIG==1)
 pulses++;//moving forward
 if(A_SIG==0)
 pulses--;//moving reverse
 Serial.println(pulses);
 attachInterrupt(1, B_FALL, FALLING);
}

void B_FALL(){
 detachInterrupt(1);
 B_SIG=0;
 
 if(A_SIG==0)
 pulses++;//moving forward
 if(A_SIG==1)
 pulses--;//moving reverse
 Serial.println(pulses);
 attachInterrupt(1, B_RISE, RISING);
}

The processing  then sketch trims off unnecessary white space and sends the data to PD as floats using the OSC messages and finally Pd recieves this data using a localhost connection.

The Processing sketch:
Code:
import processing.serial.*;
 
import oscP5.*;
import netP5.*;
// The serial port:
Serial myPort;

OscP5 oscP5;
NetAddress myRemoteLocation;


 
void setup() {
   size(400,400);
  frameRate(25);
  // List all the available serial ports:
  println(Serial.list());
 
  myPort = new Serial(this, Serial.list()[0], 9600);
 
    oscP5 = new OscP5(this,12000);
 
  myRemoteLocation = new NetAddress("127.0.0.1",12000);
     
}

 
void draw() {
      background(0); 

      String pulses_raw = myPort.readStringUntil('\n'); //read until the new line, like print ln
 
  if (pulses_raw != null) {
   
    // trim off any whitespace:
    pulses_raw = trim(pulses_raw);
   
    float pulses = float(pulses_raw);
 

println(pulses);

  // preparing message to send to PD   
 OscMessage myMessage = new OscMessage("/hello");
  //Attaches pulse values to send
  myMessage.add(pulses);
  //sends pulse data to PD
    oscP5.send(myMessage, myRemoteLocation);
   
  }
}

Quote
What happened to that idea? Seems more logical to me.
That was the original plan but I have been having a really hard time figuring how to use the encoder along with another sensor to print to serial so I can use the different values in PD. The answer may be staring me straight in the face and I may have needlessly complicated things for myself but I cannot seem to figure it out.
3  Using Arduino / Interfacing w/ Software on the Computer / Re: Processing to arduino serial question? on: April 19, 2013, 11:13:41 pm
Quote
Not likely. You may have an encoder triggering an interrupt, but the ISR does not run on the encoder.
My mistake, yes you are correct it's using interrupts.

Quote
What, exactly, needs to be reset? Some count that the ISR is incrementing?
Basically I have audio tracks in PD that are chosen by fiduscial markers. I then have a hand crank attached to the encoder that effects the speed of the track. So when a track is changed by replacing the fiduscial the encoder values need to be reset back to zero so the process can once again repeat itself.

Quote
You also seem to be having trouble expressing yourself. I don't see where having an ISR handle input from an encoder is any kind of "workaround". That is how an encoder is generally used.

I'm having trouble sending out secondary values along with the pulse data that I can use in the other programs and I can't find any examples that I can work with that would enable me to do so or if its possible (we only begun working with Arduino last semester). The fiduscial markers are the workaround I'm referring to, I was originally going to handle choosing the tracks to play in pd by using the arduino to do so (e.g button presses, rfid).   

Quote
Which you haven't described.
I hope to eventually work with the encoder using the speed at which the crank is spun at rather than the pulses, by counting the pulses per second. This will speed in the audio in PD until users find a "sweet spot" at which the track will maintain it's normal rate of play. I need to sort out communication between the 3 programs first so I can then focus on the encoder as I already have it communicating to PD through processing but not back the other way and I am currently using the pulse count to effect song speed. I then plan on having this drive a motor according to the speed also. This motor will then spin a record and will be placed inside an old gramophone to act as the user interface and hopefully drive the motor in the opposite direction using a h-bridge and the negative pulses. I didn't want to post in the wrong forum that's why I didn't fully describe my project and the concept of the project had to be developed before we even got a chance to investigate whether it was feasible or not, hence my lack of technical knowledge of the encoder.


4  Using Arduino / Interfacing w/ Software on the Computer / Re: Processing to arduino serial question? on: April 19, 2013, 06:04:51 am
I have an encoder running an ISR in Arduino that needs to be reset when the fiduscial markers are changed in PD. I've generally just been having trouble working with the encoder and this was just a workaround for me because I'm not very comfortable coding in arduino with the encoder. I kind of got thrown in the deep end with having to use it for my project.
5  Using Arduino / Interfacing w/ Software on the Computer / Re: Processing to arduino serial question? on: April 18, 2013, 09:52:58 pm
I know I could incorporate a button to solve this but presentation is counting a lot for this project I'm working on and the current design for this would make a button look fairly obvious so I'm looking for a software solution instead.
6  Using Arduino / Interfacing w/ Software on the Computer / Processing to arduino serial question? on: April 18, 2013, 08:55:40 pm
I have a message coming into processing from pure data via OSC data I'm just wondering could I use the processing arduino library to trigger a function I have in my arduino program to reset the serial data back to zero. I currently have this working with a switch but I need to change it to when I swap fiduscial markers in a pure data patch I'm making. I am unable to use pduino for this as far as I know. I just want to know if it's possible before I waste any more time attempting it. (The OSC messages can carry integer,floats etc.)
7  Using Arduino / Programming Questions / Re: Printing two sensor values? noob on: April 16, 2013, 07:01:38 pm
What I'm trying to achieve is to use the RFID reader to choose a piece of audio to affect in another program and then use the encoder to affect the speed of the chosen audio that I'll make into a crankshaft.
Code:
if (value5 ){

This part is a reset switch I was working with to reset the encoder values back to zero when the audio is changed, ideally this would happen when I switched RFID tags. As for the way the code is structured for the encoder it is part of some code I was using for a hardware debounce before I got the optical encoder today. Sorry I really should have made what I'm trying to do more clear.
8  Using Arduino / Programming Questions / Printing two sensor values? noob on: April 16, 2013, 06:32:40 pm
Hi, I'm developing a project that uses a rotary encoder and an rfid reader I have both working separately however I have no idea how to combine both of these scripts together so I can use these 2 separate sensor values in other programs I am using to complete this project. I'm just wondering could anyone point me in the right direction of what I'll need to learn to do this because coding isn't my strongest point. I'm working with an optical encoder so I'm not using any debouncing code.

Here is the encoder code I am working with:

Code:
int pulses, A_SIG=0, B_SIG=1;
int digitalInput5 = 5;  // change color
int value5 = '0';

void setup(){
  attachInterrupt(0, A_RISE, RISING);
  attachInterrupt(1, B_RISE, RISING);
  pinMode(digitalInput5,OUTPUT);

  Serial.begin(19200);
}//setup


void loop(){
  value5 = digitalRead(5);
   if (value5 ){
pulses=0;
}
 
 
}

void A_RISE(){
 detachInterrupt(0);
 A_SIG=1;
 
 if(B_SIG==0)
 pulses++;//moving forward
 if(B_SIG==1)
 pulses--;//moving reverse
 Serial.println(pulses);
 attachInterrupt(0, A_FALL, FALLING);
}

void A_FALL(){
  detachInterrupt(0);
 A_SIG=0;
 
 if(B_SIG==1)
 pulses++;//moving forward
 if(B_SIG==0)
 pulses--;//moving reverse
 Serial.println(pulses);
 attachInterrupt(0, A_RISE, RISING); 
}

void B_RISE(){
 detachInterrupt(1);
 B_SIG=1;
 
 if(A_SIG==1)
 pulses++;//moving forward
 if(A_SIG==0)
 pulses--;//moving reverse
 Serial.println(pulses);
 attachInterrupt(1, B_FALL, FALLING);
}

void B_FALL(){
 detachInterrupt(1);
 B_SIG=0;
 
 if(A_SIG==0)
 pulses++;//moving forward
 if(A_SIG==1)
 pulses--;//moving reverse
 Serial.println(pulses);
 attachInterrupt(1, B_RISE, RISING);
}


I'm attaching the rfid reader code but I am mainly reworking it from Jeremy Blums tutorials on youtube. If anyone could tell me how to go about doing this or if the code I'm trying to combine is incompatible it'll be much appreciated.

9  Using Arduino / Sensors / Re: Advice on buying a rotary encoder? on: April 12, 2013, 11:36:00 pm
Thanks!Would coding an optical encoders be the same as for a mechanical one in terms of count the rises,falls etc.? Sorry if this is a stupid question but I'm fairly new to all this.
10  Using Arduino / Sensors / Advice on buying a rotary encoder? on: April 12, 2013, 11:24:27 pm
Hi,
I've been working with some cheap rotary encoder and have tried both the hardware and software debouncing methods. Although I've had some success with both, it still wasn't working perfectly when I went down the hardware route and the code got a bit messy using the software method when trying to add extra functionality that my project requires. I'm just wondering does anyone know of any encoders out there that have little or no bouncing issues?I'm willing to spend about 40 or 50 euro as its for my final year project if anyone has any recommendations? Any advice would be greatly appreciated.
11  Using Arduino / Project Guidance / Re: Arduino powered gramophone project help, noob on: April 04, 2013, 10:46:35 am
Yes you explained it very clearly and I know now what I have to do thanks again!
12  Using Arduino / Project Guidance / Re: Arduino powered gramophone project help, noob on: April 03, 2013, 09:46:16 pm
There is but its more for aesthetic purposes and the speed of the audio will correspond to the speed at which the motor spins the record. Its just to provide another type of feedback to the user besides the audio.
13  Using Arduino / Project Guidance / Re: Arduino powered gramophone project help, noob on: April 03, 2013, 07:43:45 pm
Thanks a lot for the advice looks like I have plenty more to learn about the arduino smiley
14  Using Arduino / Project Guidance / Re: Arduino powered gramophone project help, noob on: April 03, 2013, 12:29:29 pm
Sorry I should have been clearer about that earlier but basically its using a gramophone as an interface but its not going to function in the exact same manner. Its a gramophone and when a person selects an object from a selection and places it a pedestal the arduino will recognize the RFID tag inside and select a song that corresponds to the audio. Then the user will turn the hand crank which will affect the speed of the audio until its playing at a normal speed. The audio is being handled with Pure Data and Processing and I have this working already to a degree so I won't actually be damaging a record but I still want this working for the general look of the project. I also must handle the anti clockwise turning of the hand crank and this is my main problem at the moment it is working but I am unable to do anything with the values once it goes below the 0 mark to 65535.
15  Using Arduino / Project Guidance / Re: Arduino powered gramophone project help, noob on: April 03, 2013, 11:21:14 am
Yes its 65535 I just didn't have it open in front of me at the time I posted so I was unsure of the exact value. I'm working with one of the libraries I found on this site and it works perfectly my problem is that I can't translate the larger anti clockwise values into data I can use and I'm not really sure how to as I'm new to working with the encoder and arduino in general. Ideally I'd be able to use the larger numbers but if I can't I'm wondering if its possible to still allow for back winding but to restrict the encoder from going below the zero mark? I'm sorry if this is a stupid question but I'm really stumped here. I've attached code I'm using that uses software debouncing. I just have to solve this because I still have to introduce some RFID functionality to the project that allows the gramophone to differentiate between which song it has to play when certain items are place in close proximity to it.
Pages: [1] 2