Show Posts
Pages: [1] 2 3
1  Using Arduino / Interfacing w/ Software on the Computer / Problems with Arduino and MAX/MSP (UDP communication) on: September 28, 2012, 05:59:27 am
Hello everybody, I've created a new topic a couple of weeks ago in the Software section of the forum to ask about the problem I'm going to exhibit right now. I think that asking again here will be better since the problem is (probably) not about the Arduino and it's code but MAX/MSP.

This is a prntscreen of the MAX sketch I've made

Pretty simple stuff, it collects 3 bytes generated randomly by 3 different "drunk" functions and send them via UDP to the Arduino.

This is the Arduino code
Quote
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>

#define localPort 7400

byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xE5};      
IPAddress ip(192, 168, 1, 177);                

EthernetUDP Udp;                                  

int PACKET_SIZE = 0;

void setup()                                      
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip);
  Udp.begin(localPort);
}

void loop()
{
  PACKET_SIZE = Udp.parsePacket();
  byte packetBuffer[PACKET_SIZE];
  
  if (PACKET_SIZE > 0)                            
  {
    Udp.read(packetBuffer, PACKET_SIZE);
    
    for (int i = 0; i <PACKET_SIZE; i++)
    {
      Serial.print(packetBuffer);
      
      if (i < (PACKET_SIZE - 1))
        Serial.print(", ");
      else
        Serial.println(".");
    }
  }
}

Easy, it prints unto the serial monitor the data recevied via UDP by MAX/MSP. The problem is here...


I should receive only 3 bytes, I can't understand why I get 28! Also - the correct ones - are the 20th, 24th and 28th. Seems like the others are something that comes from MAX/MSP but I don't know why and I don't know how to avoid this problem. I'm looking for some help, hope you'll enlighten me guys!
Thanks for your tips!

EDIT: I've just discovered something cool, the first 4 bytes (108, 105, 115, 116) compose the word "list", could this help?
2  Using Arduino / Programming Questions / Re: Arduino Ethernet - some issues with UDP commuication on: September 23, 2012, 05:52:16 am
Yes it was pretty easy! Line #13, instead of
Code:
char packetBuffer[PACKET_SIZE];
the correct one is
Code:
byte packetBuffer[PACKET_SIZE];

Anyway, I still can't understand why there's a misunderstanding between MAX and the Arduino.
This is my "new" arduino code
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUPD.h>

#define localPort 7401   
#define BUFFER_SIZE 12   

byte mac[] = {0x90, 0xA2, 0xD3, 0xE0, 0x66}; 
IPAddress ip(192, 168, 1, 177);             

byte packetBuffer[BUFFER_SIZE];               

EthernetUDP Udp;                             

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Udp.begin(localPort);
}

void loop()
{   
  if (Udp.parsePacket() > 0)   
  {


    Udp.read(packetBuffer, BUFFER_SIZE);   
    for (int i = 0; i < BUFFER_SIZE; i++) 
    {
      Serial.print(packetBuffer[i]);
      if (i < 11)
        Serial.print(", ");
      else
        Serial.println(".");
    }   
  }
}

What I obtain is:
105, 110, 116, 0, 44, 105, 0, 0, 0, 0, 0, number. (number is what MAX sends)

The values before "number" never change

If I add the line - Serial.println(Udp.parsePacket()); - after line#23 I obtain:
0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.

I don't know if you're good with MAX (I am not, these are the very first sketch I make) but I will upload the "code"

Also this is pretty easy and I can't see mistakes or something.

Need help! Thanks
3  International / Software / Re: Ricevere bytes via UDP on: September 23, 2012, 05:06:35 am
UP era molto semplice, basta dichiarare all'inizio l'array packetBuffer di tipo BYTE invece che CHAR
4  International / Software / Ricevere bytes via UDP on: September 22, 2012, 08:41:28 am
Ciao a tutti, ho scritto un piccolo codice (sull'Arduino Ethernet) che assomiglia molto a quello presente nel tutorial. Posto lo sketch di seguito:
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>

#define localPort 7400                            
#define PACKET_SIZE 384

byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xE5};      
IPAddress ip(192, 168, 1, 177);                    

EthernetUDP Udp;                                  

char packetBuffer[PACKET_SIZE];                    

void setup()                                      
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip);
  Udp.begin(localPort);
}

void loop()
{
  int packetSize = Udp.parsePacket();              
  if (packetSize)                                  
  {
    Serial.print("The incoming packet is ");        
    Serial.print(packetSize);
    Serial.println(" bytes long");
    
    Serial.println("It contains the following characters:");
    Udp.read(packetBuffer, PACKET_SIZE);
    
    Serial.println(packetBuffer);
  }
}

Per la comunicazione uso MAX/MSP. Non ho alcun problema a parte il fatto che se al posto di inviare una stringa di caratteri cerco di inviare un numero (intero) ottengo il seguente messaggio nella finestra "serial": It contains the following characters: int

Devo modificare il programma in MAX oppure l'Arduino ha un limite e devo usare altre funzioni/strategemmi per poter ricevere correttamente i dati "non-string"?
*PS: piĆ¹ che altro sono interessato alla ricezione di bytes

Grazie per gli aiuti!
5  Using Arduino / Programming Questions / Re: Arduino Ethernet - some issues with UDP commuication on: September 22, 2012, 04:28:07 am
Sorry guys I've been out for few days and I couldn't reply here. Anyway:

Code:
 int packetSize = Udp.parsePacket();              
  if (packetSize)                                  
  {
    Serial.print("The incoming packet is ");        
    Serial.print(packetSize);
    Serial.println(" bytes long");
packetSize isn't a boolean, and shouldn't be used like one. If you want to do something only when packetSize is greater than 0, make that explicit.
This is true, I didn't notice that "mistake" while copying the code prom the example.

I've used the Processing code here instead of MAX and the Arduino counts correctly the incoming bytes, it's weird how MAX is missing something. I need to check and see what's the problem there. However, I still need to understand how to receive bytes instead of char strings.

@SufferTim: I don't need to send non-string data, I need to READ non-string data on my Arduino. Anyway, the function you wrote down could be helpful. Thanks for your tips!
6  Using Arduino / Programming Questions / Arduino Ethernet - some issues with UDP commuication on: September 20, 2012, 05:18:47 am
Hello everybody, I'm using an Arduino Ethernet and I'm trying to learn something about it. I've recently played around with some example for the UDP communication and I've found out something which I can't understand.

This is my code:
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>

#define localPort 7400                            
#define PACKET_SIZE 384

byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xE5};      
IPAddress ip(192, 168, 1, 177);                    

EthernetUDP Udp;                                  

char packetBuffer[PACKET_SIZE];                    

void setup()                                      
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip);
  Udp.begin(localPort);
}

void loop()
{
  int packetSize = Udp.parsePacket();              
  if (packetSize)                                  
  {
    Serial.print("The incoming packet is ");        
    Serial.print(packetSize);
    Serial.println(" bytes long");
    
    Serial.println("It contains the following characters:");
    Udp.read(packetBuffer, PACKET_SIZE);
    
    Serial.println(packetBuffer, PACKET_SIZE);
  }
}

Pretty easy, it seems a lot like the one in the tutorial but has less functions. Mine should print the size of the packet and its contents (that's exactly what it does).
The problems with the output are:
1) why if I send a string (I use MAX/MSP to do so) composed by the characters "abcde" (with no " obviously) the Arduino says that the string is 12 bytes long? That's not true , it should be 5 bytes long unless I'm missing something.
2) I'd like to send bytes/integer numbers instead of strings but I can't because when I do so (i.e. I send the number 255 with MAX) I obtain the following message: It contains the following characters: int

For the 2nd I probably need to create a new function into the EthernetUDP class but I have no idea about the first issue. Thanks for your help
7  Using Arduino / General Electronics / Re: What's the purpose of these pull-up resistors? on: September 12, 2012, 02:54:35 pm
I got your point, thanks for the explanations!
8  Using Arduino / General Electronics / Re: What's the purpose of these pull-up resistors? on: September 12, 2012, 09:26:38 am
Ok, what do you think about series resistors at the outputs of the 74HC138? I'd use them (something like 220-330 Ohm) in order to limit the output current when the gate capacitor is discharged. I honestly think that they're needed to avoid damages at the IC.
9  Using Arduino / General Electronics / Re: What's the purpose of these pull-up resistors? on: September 12, 2012, 07:46:43 am
Thanks for your response, it makes sense to me. Same applies for the pull-down probably resistors upon the IRF7314s drains, do you agree?
10  Using Arduino / General Electronics / What's the purpose of these pull-up resistors? on: September 12, 2012, 07:25:51 am
Hello everybody, I'm taking a look at this schematic which represents a controller for a 16x8 RGB LED matrix. I can't understand why there are pull-up resistors at the output of the 74HC138 since this component is not an open collector type. Firstly I thought that they invert the 138 output signal (I'm not sure about that tho); if this was their purpose, wouldn't be better using a 74HC238 which is exactly the same of his "brother" but has an 'active HIGH' tecnology? Thanks for replies
11  Using Arduino / LEDs and Multiplexing / Re: 8x8 Matrix LED problem on: May 16, 2012, 12:26:22 pm
Did you use current limitating resistors?
12  Using Arduino / LEDs and Multiplexing / Re: Need help to control a high power LEDs matrix on: May 14, 2012, 08:39:23 am
Ok, now I got your point (; So the FET gate acts like a kind of low-pass filter more or less. Sorry if I ask basics concepts of the electronics but I didn't study the FETs at high school so now I feel a bit lost when I read very technical replyes. Anyway, everything's clear now... About the project, I thought about using some drivers which could help me a lot: CAT4101. I've also looked for some high speed MOSFETs and found this which could be useful. They look fast enough, since the propagation delay is ~30ns if 5V are applied to the input (anyway, as jwatte said, I don't think I'll have a lot of problems with the propagation times in any case since the frequency isn't that high and I can adjust in order to make it as fast as it needs to be). I'll buy some components as soon as I can and try these wirings, thank you all for your inputs! I will write something to make you know how the stuff goes on and to ak something if needed!   smiley-lol
13  International / Generale / Re: Arduino ethernet getting started on: May 13, 2012, 01:13:01 pm
Molto utile grazie mille (:
14  Using Arduino / LEDs and Multiplexing / Re: Need help to control a high power LEDs matrix on: May 13, 2012, 12:16:37 pm
I agree with jwatte's solution, if I set the resistor between the Vout and ADJ pins the output current isn't going to change depending on the load in order to the fixed voltage between these pins (~1,25 V). The output voltage changes.

I have few questions tho; shouldn't the MOSFETs be an N-channel and a P-channel, as you said in your previous post? I also didn't understand how can the Arduino output current affect the switching speed of the FETs (we should talk about the 74HC595 output current, but let's assume it's the same to make it easier) since the MOSFET input resistence is close to infinte, so no current flows into the gate (just a small leakeage one). On the BS170 datasheet I can read that tON = tOFF = 10nSec. Another point is that I don't think using just one current source for the whole circuit is a good idea. I should allow it to draw the current for 8 LEDs (0.35*8 = 2.8A). This means that if I turn on 8 LEDs at a time evey load will get 350mA, but if I turn a single LED on, it will receive the whole current. So I think that every LED need his own current source.

Thanks for your help
15  International / Generale / Re: Arduino ethernet getting started on: May 13, 2012, 10:36:48 am
Quale?
Pages: [1] 2 3