Show Posts
Pages: 1 2 [3] 4 5 6
31  Using Arduino / Installation & Troubleshooting / Re: Mega 2560 Serial Monitor on: July 01, 2011, 08:48:44 pm
I tried the manual reset... and it didn't work as I expected.  Basically, when I upload the sketch and then I launch the Serial Monitor... it takes anywhere from 7-10 seconds to start receiving values... when I then hit the manual reset, it pauses for about maybe 0.5 to 1 second before sending values again... but definitely not as long as it takes the very first time I launch the Serial Monitor.  I'm using the IDE ver. 0022.  And I've never had any sort of problem like this with my Uno.  Do you think this is a faulty board?  Or is this normal behaviour?
Thanks again,
Andy
32  Using Arduino / Installation & Troubleshooting / Mega 2560 Serial Monitor on: June 30, 2011, 02:26:18 pm
I just bought a new Mega 2560 and I'm having a problem with it, right off the bat... I don't know if this problem is the same as the other ones reported, but I am at least able to upload sketches to the board without problem (it seems other could not)... But, my problem is with the Serial Communication.  When I upload the AnalogSerialRead sketch (Under the Examples\Basics tutorials) I would expect that when I launch the Serial Monitor that it would immediately start printing values from APin0 in the monitor.  On the Uno, this happens nearly instantaneously.  But, when I upload this sketch it takes about 7-10 seconds before anything starts happening.  I've made sure I'm on the same Baud Rate...  Again, this is just a basic test, but it happens on every sketch I upload that has information printing to the Serial Port.  Is this a bug?  Do I need to follow the hack instructions for updating the DFU?  Or is this just faulty hardware?  Any thoughts?
Thanks,
Andy
33  Using Arduino / General Electronics / Re: MOSFET Power Control Kit on: April 13, 2011, 05:40:07 pm
Quote
Well you gave us a spec of 400ma for the wire, but not what resistance the wire has at that current.

Thanks for the detailed reply.  The technical info on the SMA wire says that the resistance is 1.4 Ohms/inch and I'm using a 12" piece so that equates to 16.8 (or roughly 17 ohms) resistance.  I could be wrong, but if my calculation is correct... then the voltage drop at 400mA and 16.8 ohms resistance would be 6.72Volts (does that seem correct?).  If it is, then using your equation (12vdc - wire drop voltage)/0.400A = 13.2 ohms.  So, should I use a 13 ohm resistor between the +12vdc and the + pin on the MOSFET? (sorry if this is obvious)

Also, you mentioned using a PWM for the MOSFET control signal.  I thought I was supposed to use a digital signal (HIGH/LOW) which would trigger the MOSFET to allow the 12vdc to flow through the wire... Is this not correct?  If I use a PWM... does that mean I could send a PWM value of 0 to turn it off and 255 would be full bore... but I could get gradients in between?  That would actually be great if so.... I just didn't know that was possible.

Also, I was a little confused by your last paragraph.  The power supply I'm using is a version of a wall wart (http://www.adafruit.com/index.php?main_page=product_info&cPath=44&products_id=329).  I also bought the barrel jack connector (http://www.adafruit.com/index.php?main_page=product_info&cPath=44&products_id=327) and thought that I one side of this connector would be power and the other side ground... I had thought I could hook up the side with the white stripe running down the side to the positive pin on the MOSFET and the other side to the negative pin on the MOSFET.  You suggested that I run a wire from my ground pin on my arduino to the negative pin on the MOSFET instead.  Does it matter which ground I use? 

Thanks again
34  Using Arduino / General Electronics / MOSFET Power Control Kit on: April 13, 2011, 03:25:45 pm
I'm wondering if I could get some help connecting my MOSFET Power Control Kit (http://www.sparkfun.com/products/10256) to my Arduino.  Basically, for my application I'm trying to send a current through 12" of a Shape Memory Alloy wire (0.006" dia.)  The data sheet on the SMA wire recommends that you should send 400mA of current through the wire to heat it up to its transition temperature to get it to contract.  Since, a pin on the Arduino can only source 40mA, I figured I'm going to need to use an external power source to supply more power to the SMA's.  I've got a 12V 1000mA regulated DC power source that I want to use and I figured I could use one of the digital pins on the Arduino to trigger when the MOSFET should send the power from the external power source over to the SMA wire.  Hopefully, my logic is sound.  Since this is my one of the first times I've used a little bit more power in one of my projects, I just want to make sure I set everything up properly so I don't burn anything out.
Looking at the Power Control Kit break out board, it seems like what I need to do is to connect a wire from a digital pin on the Arduino to the C pin on the break out board.  Then connect the + and - side of the power source to the other two pins on that side.  Obviously the SMA wire ends will go on the device side.  My question is, do I need a resistor in circuit with the power source to limit the amount of current?  Using Ohm's law, it seems like if I really want 400mA current to flow through and I'm supplying 12V that I'll need a 30 Ohm resistor.  Would this go inline on the high side of the external power supply?  Also, is there any reason to be concerned that the Digital Pin wont be able to supply enough current to trigger the MOSFET?  Sorry, if a lot of these are beginner level questions, but I would really appreciate any feedback before I test this out.

35  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: September 02, 2009, 08:53:14 am
The problem is that I need the numbers to be numbers and not strings... is there any way to keep then still numbers but keep their formatting?
36  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: September 02, 2009, 12:39:14 am
Hi Rob,
I had one follow up question I was hoping you might be able to help me with.  I am trying to bring in the accelerometer data from a wii remote into Grasshopper.  I've got 2 lines in my Arduino code that prints 2 different lines, each with a number for the two directions of the accelerometer.
Code:
Serial.println((byte)accx,DEC);
Serial.println((byte)accy,DEC);
So, when I turn on the Serial Monitor... I get two numbers, each on their own line (which makes sense, because I'm using the println command)... However, when I read this data into Grasshopper... it combines both numbers into 1 larger number... so if my accx number = 172 and my accy number = 105, then the number that comes into Grasshopper is 172105.  If they came into Grasshopper on 2 consecutive lines then I can split the list into 2 and isolate each number... but it's more difficult when the number is combined into one 6 digit number... Is there anything in the code that would be combining the 2 numbers into 1 line?  Here is the code that we came up with.
Code:
 Sub RunScript(ByVal StepNumber As Integer)
  
    Select Case StepNumber
      Case 0
        OpenPort()
        Print("Port has been opened")
      Case 1
        'Print(StoredValue)
        Print(CInt(Val(StoredValue)))
      'A = StoredValue
      Case 2
        ClosePort()
        Print("Port has been closed")
    End Select
  End Sub

#Region "Additional methods and Type declarations"

  ' I wrapped this in a class, but you would need to work it into the grasshopper class

  Private WithEvents CPort As New IO.Ports.SerialPort        'port with events
  Private TempBuffer As String = String.Empty            'holds the input between events until we get a new line
  Private Delegate Sub HandleComPortDelegate()  'allows com port to run in a background thread without blocking
  Private StoredValue As String = String.Empty  'holds value from port until you call for it

  Sub OpenPort()              'called early in the app, before the port is ever needed. This attaches the port, and opens it to listen.
    Try
      If CPort.IsOpen = False Then
        CPort = My.Computer.Ports.OpenSerialPort("COM3", 9600)
      End If
    Catch ex As Exception
      'MessageBox.Show("no port")
      MessageBox.show(ex.tostring)
    End Try
  End Sub

  'this would be better as a property, but I don't know how Grasshopper handles properties
  Function GetValue() As String
    Return StoredValue
  End Function

  'this is fired by the port when it has data
  Private Sub CPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles CPort.DataReceived
    Dim HndlComPort As New HandleComPortDelegate(AddressOf HandleComPort)             'declare thread
    HndlComPort.Invoke() ' invoke a new delegate to digest the events

  End Sub

  Private Sub HandleComPort()        'background handler for com port

    TempBuffer &= CPort.ReadExisting  'append into tempbuffer
    If (Strings.Right(TempBuffer, 2) = vbCrLf) Then        'if end of item            'this may need to be changed, since Arduino's println may use cr or lf only. I can't remember at this point.
      StoredValue = TempBuffer             'offload
      TempBuffer = String.Empty             'reset
    End If

  End Sub

  'should be called when the port is no longer needed.
  Private Sub ClosePort()
    If CPort IsNot Nothing Then
      If CPort.IsOpen = True Then
        CPort.Close()
      End If
      CPort.Dispose()
    End If
  End Sub
#End Region
37  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: August 31, 2009, 11:32:28 pm
This is great... It's totally working... I rigged up my arduino to read a simple photocell setup... I used your trick to convert the string to a number before sending it to the text panel... And then I just feed the data from a text panel to drive the radius of a circle... I know that's pretty simple... but it totally works.  Below is a screenshot of the definition setup and I've set the Timer interval to 100ms so the data stream is fairly smooth (I think 50ms is the lowest I can go in Grasshopper).  So, I just shine a flashlight on the photocell... and the circle changes shape... My next step is going to be reading in the data from a wii remote (I've already gotten the wii remote to drive a pan/tilt servo... but I wanted to try to recreate the motion in Grasshopper).  But, I think the steps should be fairly straight forward.  Thanks again for all of you help... I never would have made it this far without your help.  If your ever out in the Bay Area... definitely let me know... I owe you a beer (or several).

http://www.liftarchitects.com/storage/research/Arduino%20to%20Grasshopper_working01.jpg
38  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: August 31, 2009, 10:56:37 pm
It's really weird... Sometimes I get that error message that I just told you about... but I unplugged the Arduino again... and closed Rhino... I restarted everything... and now everything is working perfectly.  I changed the process of feeding the StepNumber... Before I was using a slider so that I either had to go from 0,1, and then 2... but to get back to 0 to open the port... you had to first pass the number 1 to the code... which I think was part of the problem... Now, I just have three parameters, each containing a single number.  Now, I just connect the first parameter to open the port... Then I connect the Get Value parameter (number 1).  Then I close the port... only now, I just re-connect the Open Port parameter and re-trace my steps... and it seems to work.  
So, as for the string to number conversion...  The string is just coming in because we have defined the "Private StoredValue As String = String.Empty".  Wouldn't we want to change this part of the code so it thinks the data coming in isn't a string but instead a number?  I can't think of a way off the top of my head for Grasshopper to convert the string to a number after the fact.  I will play around with some different techniques... but if you think changing the VB code to read the numbers directly... let me know.
39  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: August 31, 2009, 10:29:58 pm
Also... I have one other follow up question... I noticed that the numbers coming in over the COM port are some value between 0-1024 (this makes sense... I have a potentiometer coming in so it would be read as a 10bit number)  However, I've noticed that the data type is a "string" and not an integer... But, this is a little unfortunately because I'd like to be able to take those integers and feed them into some component that requires a number... but since Grasshopper thinks the data coming in is a String... it can't read the numbers... How would I modify the code to convert those strings to integer values?  Thanks again for all the help... I feel like we made huge progress (even though there are still some kinks to work out).  
40  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: August 31, 2009, 10:23:41 pm
Actually! It worked... I don't know what the difference was... but I unconnected the Arduino and closed the program... and re-tried everything... Only this time when I opened the file... it works.  I'm getting a stream of data from the potentiometer... just like the serial monitor.  It's great...
I did notice something odd though.  When I go and update the code (I wanted to take the extra print line out of the VB script)... when I return to the Grasshopper canvas... even though the StepNumber is set to 1... I'm not getting anything coming out of the Out box... So, I plugin the number 2 to close the port... and when I try to re-open the port by plugging in the number 0... I get that error message again, saying "No Port".  Then, I can no longer get the streaming numbers back... unless I close the entire program and re-launch it.  Can you think of any ideas why this would be?
41  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: August 31, 2009, 10:15:51 pm
Hi Rob,
I tried out the script you wrote.  When I first run the script, I make sure that the StepNumber is set to 0 to open the port.  Then I switch the StepNumber to 1... but nothing happens.  I did put in another print line just to see if it was calling Step 1... and it does make it into the loop... but it isn't returning any values for the StoredValue from the COM port.  So, I then switch the StepNumber to 2 to close the port.  When I retrace the steps (meaning... I've connected a slider to the input... so to get back to 0, I first have to slide to 1 and then to 0 to open the port)... The funny thing is, that when I get back to 0... I get that same error message that says "No Port".  Which seems odd because you would think that the port would have been closed when I took the slider up to 2.  Perhaps there is an error in the close port method too.  Do you have any ideas?  Also, why would it not be reporting whatever the StoredValue is the first time I input the number 1 into the StepNumber?  Any ideas?  
42  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: August 31, 2009, 09:07:14 pm
Rob, here is the code where I last left off.  Basically, I'm feeding a variable input called StepNumber (which is either a 0,1, or 2) to call one of the three different Case functions.  We figured out that it's getting stuck when the Timer component tries to rebuild the solution that it's trying to continually re-open the port.  

Code:
 Sub RunScript(ByVal StepNumber As Integer)
  
    Select Case StepNumber
      Case 0
        OpenPort()
        print("Port has been opened")
      Case 1
        print(storedvalue)
      Case 2
        ClosePort()
        print("Port has been closed")
    End Select
 
  End Sub

#Region "Additional methods and Type declarations"

  ' I wrapped this in a class, but you would need to work it into the grasshopper class

  Private WithEvents CPort As IO.Ports.SerialPort      'port with events
  Private TempBuffer As String = String.Empty        'holds the input between events until we get a new line
  Private Delegate Sub HandleComPortDelegate()      'allows com port to run in a background thread without blocking
  Private StoredValue As String = String.Empty      'holds value from port until you call for it

  Sub OpenPort()            'called early in the app, before the port is ever needed. This attaches the port, and opens it to listen.
    CPort = New IO.Ports.SerialPort

    Try
      CPort = My.Computer.Ports.OpenSerialPort("COM3", 9600)
    Catch ex As Exception
      MessageBox.Show("no port")
    End Try
  End Sub

  'this would be better as a property, but I don't know how Grasshopper handles properties
  Function GetValue() As String
    Return StoredValue
  End Function

  'this is fired by the port when it has data
  Private Sub CPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles CPort.DataReceived
    Dim HndlComPort As New HandleComPortDelegate(AddressOf HandleComPort)             'declare thread
    HndlComPort.Invoke() ' invoke a new delegate to digest the events

  End Sub

  Private Sub HandleComPort()      'background handler for com port

    TempBuffer &= CPort.ReadExisting  'append into tempbuffer
    If (Strings.Right(TempBuffer, 2) = vbCrLf) Then        'if end of item            'this may need to be changed, since Arduino's println may use cr or lf only. I can't remember at this point.
      StoredValue = TempBuffer               'offload
      TempBuffer = String.Empty               'reset
    End If

  End Sub

  'should be called when the port is no longer needed.
  Private Sub ClosePort()

    If CPort.IsOpen = True Then
      CPort.Close()
    End If
    CPort.Dispose()

  End Sub
#End Region
43  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: August 31, 2009, 05:07:33 pm
Hi Rob,
Sorry to hear you had to work all weekend smiley-sad  I actually have the latest file at home (I don't have it here at work).  I can post/email you the current script file as soon as I get home in a few hours (probably around 6:30 PST).  Thanks again for your help.
44  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: August 31, 2009, 09:08:25 am
Hi Rob.  I hope you had a great weekend.  I was wondering if you had had a chance to look at the issue that was creating the error trap when opening the port... that we talked about on Friday.
45  Forum 2005-2010 (read only) / Interfacing / Re: Sending Data to Serial Port through VB on: August 28, 2009, 09:04:46 pm
You can always download the trial version http://www.rhino3d.com/download.htm.  This one is the full version... however, it only allows you to save Rhino 25 times... You'll also want the Grasshopper plugin, which is free: http://grasshopper3d.ning.com/forum/topics/grasshopper-060019-available.  The nice thing about this setup... is that you can save as many Grasshopper files as you want... as long as you don't save the actual Rhino files (The Grasshopper interface is a completely different interface... so you save as many Grasshopper files .ghx without ever causing the Rhino eval version to expire...I think this would make sense if you install both packages).  I've actually written a 150 page manual about helping beginners get up to speed with the plugin and you can download it for free on my website: http://www.liftarchitects.com/downloads/.  Maybe this could help us figure this thing out.
Pages: 1 2 [3] 4 5 6