Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Dave M.'s Content

There have been 40 items by Dave M. (Search limited from 30-March 23)


By content type

See this member's


Sort by                Order  

#51053 SPI.configuration and L6470 Stepper Driver

Posted by Dave M. on 03 July 2013 - 04:22 PM in Netduino 2 (and Netduino 1)

I'm an idiot.  I misread the timing diagram and blindly interpreted MSB as MS BYTE, even though the CK line clearly implies that this is MS BIT.  :)  Ok, things are getting better now on my end.  I'll look into the special hardware hack mentioned earlier.




#51051 SPI.configuration and L6470 Stepper Driver

Posted by Dave M. on 03 July 2013 - 03:55 PM in Netduino 2 (and Netduino 1)

So.... how are things going, Kristoffer?  :)

 

It turns out that I'm trying to get my L6470 eval kit working with both the Netduino Plus and mbed LPC1768, and I have had no luck with either.  I actually posted here recently: http://forums.netdui...h-time/?p=50999

 

I'm glad I found your post because it might help me to get further along.  One thing that might be tripping me up is the issue with CS having to be toggled after each byte.  It does say that in the text, but when I implemented mine, I used Figure 18 (timing diagram) instead.  This timing diagram says the exact opposite, if I'm reading it correctly -- that you can clock the MSB to LSB out with CS kept low.  How confusing!

 

I also have a different SPI configuration than you.  From the datasheet, I interpreted the clock's idle state to be high, and to look for a low-high clock transistion for the data.  Therefore, my config looks like this:

SPI.Configuration l6470 = new SPI.Configuration( Pins.GPIO_PIN_D2,                                                 false,                                                 1,                                                 1,                                                 true,                                                 true,                                                 100,                                                 SPI_Devices.SPI1);

Note that I am purposely running at 100kHz because my logic analyzer doesn't have enough memory to be able to reliably capture data.

 

On the mbed side, everything I send to the L6470 gets echoed back, which is weird.  On the NP, I get weird bit shifting effects where a bit shifts from the MSb to the LSb when I just send NOPs continuously.

 

If you have gotten yours to work, then I'm going to try using your config parameters to see if I get better results.  It would be great to hear how your L6470 project is going now!




#50999 SPI clocking in single shifting bit each time...

Posted by Dave M. on 01 July 2013 - 10:23 PM in Netduino Plus 2 (and Netduino Plus 1)

Maybe I should have posted my firmware info as well.  From this post, it sounds like people have had issues with SPI, though that still might not be what's causing my problem.

 

Oops... and I just realized that I am running on a Netduino Plus, not a NP2, so I have no idea what is expected, considering that I have the SDK for the NP2 installed on this computer.  I'll try my NP2 instead to see if there's any difference.

Pinging... TinyCLRHalSystemInfo.halVersion:               4.2.0.0HalSystemInfo.halVendorInfo:            Netduino Plus (v4.2.0.1) by Secret Labs LLCHalSystemInfo.oemCode:                  255HalSystemInfo.modelCode:                255HalSystemInfo.skuCode:                  65535HalSystemInfo.moduleSerialNumber:       FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFHalSystemInfo.systemSerialNumber:       FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFClrInfo.clrVersion:                     4.2.0.0ClrInfo.clrVendorInfo:                  Netduino Plus (v4.2.0.1) by Secret Labs LLCClrInfo.targetFrameworkVersion:         4.2.0.0SolutionReleaseInfo.solutionVersion:    4.2.0.0SolutionReleaseInfo.solutionVendorInfo: Netduino Plus (v4.2.0.1) by Secret Labs LLCSoftwareVersion.BuildDate:              Sep 19 2012SoftwareVersion.CompilerVersion:        410894FloatingPoint:                          TrueSourceLevelDebugging:                   TrueThreadCreateEx:                         TrueLCD.Width:                              0LCD.Height:                             0LCD.BitsPerPixel:                       0AppDomains:                             TrueExceptionFilters:                       TrueIncrementalDeployment:                  TrueSoftReboot:                             TrueProfiling:                              FalseProfilingAllocations:                   FalseProfilingCalls:                         FalseIsUnknown:                              False



#50986 SPI clocking in single shifting bit each time...

Posted by Dave M. on 01 July 2013 - 02:13 PM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for your input, Mark.  I'm using an ST L6470 stepper driver.  I'll attach the datasheet and the screenshot to my original post.  I believe I have the SPI configuration correct, but clearly something is wrong so I'd appreciate any extra eyes on the timing diagram!  :)




#50901 SPI clocking in single shifting bit each time...

Posted by Dave M. on 28 June 2013 - 05:00 PM in Netduino Plus 2 (and Netduino Plus 1)

I had gone straight to the SPI protocol analyzer last time, instead of looking at the traces.  In the second attachment in my original post, you will see that SCK transitions from high to low for some strange reason, so perhaps this is what's causing the problem.  But why wouldn't SCK stay high after transmitting each byte???




#50900 SPI clocking in single shifting bit each time...

Posted by Dave M. on 28 June 2013 - 04:52 PM in Netduino Plus 2 (and Netduino Plus 1)

I've been having trouble interfacing with a device using SPI, and finally I decided to use my logic analyzer to monitor the data.  The chip has a NOP command, so basically I'm just calling SPI.WriteRead( new byte[1] {0}, new byte[1] {0}) in a tight loop to see what happens.

 

It looks like the first NOP goes out correctly, but each successive NOP actually clocks out a bit where it shouldn't be.  The additional bit looks like it shifts down each time, which makes no sense to me.  Can anyone provide me with ideas as to what could cause this sort of behavior?

 

I imagine that the data in the MISO column is just whatever the device is sending back in response to what command it *thinks* it's getting from the Netduino, so for now I'm concentrating on making sure that only zeroes get clocked out in my test app.

 

Here is my SPI configuration code:

SPI.Configuration l6470 = new SPI.Configuration( Pins.GPIO_PIN_D2, false, 0, 0, true, false, 1000, SPI_Devices.SPI1);SPI spi = new SPI( l6470);OutputPort standby = new OutputPort( Pins.GPIO_PIN_D3, true); // standby / rst is active low

Attached Thumbnails

  • netduino_spi.png
  • netduino_spi_sclk_high.png
  • l6470 spi timing diagram.png

Attached Files




#45263 Netduino Plus 2 Firmware v4.2.2 (update 2)

Posted by Dave M. on 10 February 2013 - 07:30 PM in Netduino Plus 2 (and Netduino Plus 1)

Thanks, Dave.  Can you suggest other ways for me to determine what's going on?  What I am seeing is that, running the same project, firmware 4.2.1.1 works, but when I run 4.2.2.2, the SDA and SCL lines stay high.  Each time I reprogram, I follow the instructions and disconnect / reconnect the hardware.  The only thing odd in the entire process is that firmware upload verification crashes the ST application.




#45251 Netduino Plus 2 Firmware v4.2.2 (update 2)

Posted by Dave M. on 10 February 2013 - 03:01 PM in Netduino Plus 2 (and Netduino Plus 1)

I've confirmed by going back and forth between 4.2.1.1 and 4.2.2.2 that the latter update causes I2C to not work again.




#45250 Netduino Plus 2 Firmware v4.2.2 (update 2)

Posted by Dave M. on 10 February 2013 - 02:38 PM in Netduino Plus 2 (and Netduino Plus 1)

I could be wrong, but this update seems to have broken I2C.  When my SDA/SCL lines were inactive under 4.1.1 while my program was running (verified with my logic analyzer), I found the I2C firmware fix update and loaded it.  Once I did that, my I2C bus started to work.  But in the process of debugging a STDFU app crash, I found out from another member about firmware 4.2.2, so I loaded it.  And now my I2C bus doesn't work again.  Has anyone else out there noticed this?  I'm going to downgrade the firmware again and will let you know what happens.




#45248 Netduino Plus 2 Firmware v4.2.1 (Update 1)

Posted by Dave M. on 10 February 2013 - 02:26 PM in Netduino Plus 2 (and Netduino Plus 1)

Sorry, I should have just tried rebooting before that last post.  I did that and it was able to reflash.  However, it is still crashing after the upload.  I'll check my settings vs. carb's, and will try debugging my app again.  Perhaps I should try the x32 version even though I'm on x64.

 

EDIT -- everything seems to be working even though verification crashed.  I can run my app again!




#45247 Netduino Plus 2 Firmware v4.2.1 (Update 1)

Posted by Dave M. on 10 February 2013 - 02:07 PM in Netduino Plus 2 (and Netduino Plus 1)

Bummer, I cannot update my firmware because STDFU no longer recognizes the device.  I held Reset and plugged in, then ran STDFU and nothing shows up in the device list.  I'll try rebooting, since that actually worked for me on another firmware upgrade issue in the past with the Netduino Plus.




#45245 Netduino Plus 2 Firmware v4.2.1 (Update 1)

Posted by Dave M. on 10 February 2013 - 01:59 PM in Netduino Plus 2 (and Netduino Plus 1)

Dave,

 

This is what I get from my Netduino Plus 2 that has been updated to 4.2.2

HalSystemInfo.halVersion:               4.2.0.0...Profiling:                              FalseProfilingAllocations:                   FalseProfilingCalls:                         FalseIsUnknown:                              False

Hope this helps,

Chuck

 

There's a 4.2.2?  :)  I usually don't keep up with updates unless something is busted.  I found 4.2.1.1 via my I2C problems and searching.  So I guess I'll try 4.2.2 now and see what happens.  Thanks for posting!  I'll compare your info to mine once I'm done.




#45242 Netduino Plus 2 Firmware v4.2.1 (Update 1)

Posted by Dave M. on 10 February 2013 - 01:43 PM in Netduino Plus 2 (and Netduino Plus 1)

I updated today because I needed to get I2C working (was previously using 4.2.1.0 and logic analyzer wouldn't see anything on SDA/SCL). Anyhow, the process worked fine and I was able to upload, but during verification the app keeps crashing. I ended up power cycling the N+2 and MFDeploy shows the following:  

HalSystemInfo.halVersion:			   4.2.0.0HalSystemInfo.halVendorInfo:		    Netduino Plus 2 (v4.2.1.1) by Secret Labs LLCHalSystemInfo.oemCode:				  34HalSystemInfo.modelCode:			    177HalSystemInfo.skuCode:				  4102HalSystemInfo.moduleSerialNumber:	   00000000000000000000000000000000HalSystemInfo.systemSerialNumber:	   0000000000000000ClrInfo.clrVersion:					 4.2.0.0ClrInfo.clrVendorInfo:				  Netduino Plus 2 (v4.2.1.1) by Secret Labs LLCClrInfo.targetFrameworkVersion:		 4.2.0.0SolutionReleaseInfo.solutionVersion:    4.2.1.1SolutionReleaseInfo.solutionVendorInfo: Netduino Plus 2 (v4.2.1.1) by Secret Labs LLCSoftwareVersion.BuildDate:			  Nov 30 2012SoftwareVersion.CompilerVersion:	    410894FloatingPoint:						  TrueSourceLevelDebugging:				   TrueThreadCreateEx:						 TrueLCD.Width:							  0LCD.Height:							 0LCD.BitsPerPixel:					   0AppDomains:							 TrueExceptionFilters:					   TrueIncrementalDeployment:				  TrueSoftReboot:							 TrueProfiling:							  FalseProfilingAllocations:				   FalseProfilingCalls:						 FalseIsUnknown:							  False

Honestly, I do not understand what each line item means, but it shows 4.2.1.1 in several places, so do you think it flashed ok? EDIT -- ok, my guess is "no". I went ahead and debugged my app, and I2C started to work. However, the 2nd time I went to run my app, it failed to deploy. This happens to me *a lot*, and I used to just disconnect / reconnect the N+2. However, this often results in a BSOD, so I started to disable the device in the Device Manager, unplug / replug, then enable the Netduino. Unfortunately, now it just come up as "Unknown Device". Since Windows already knew what the N+2 was and now it doesn't, all I can assume is that something is messed up internally now. Any ideas? :)




#45206 I2CBus

Posted by Dave M. on 09 February 2013 - 03:11 PM in Project Showcase


    [*]the LockObject has no sense, because you are locking just the I2CBus instance creation, but the further usage is not thread-safe at all;
    [*]consider two threads using the I2CBus: they don't work properly.
    [/list]The thread-safety on drivers like I2C or SPI is a much more complex task, and cannot be solved with a simple lock.

 

Can you clarify why his usage of the lock isn't thread-safe?  Other than possible performance considerations with an exclusive lock, why wouldn't his approach work, since the read and write operations are contained within the lock?

 

But in general I agree - the code isn't well written at all and probably unnecessary as you noted. Posted Image

 

I don't think Mario was saying that the code wasn't well written at all, he had some suggestions.  However, if you are going to say this, it would be more helpful to explain to the OP what you thought was lacking!




#43631 Lightweight JSON parser

Posted by Dave M. on 17 January 2013 - 11:26 PM in Project Showcase

@H07R0D cool, thanks, I'll take a look at it.  That's the other one I had found but never looked at it.  I'm glad to hear that it works.

 

The main problem I've come across with the JSON parser in this thread is that it doesn't deal with nested values too well.  I was going to hack in a fix, but haven't gotten around to it yet because I keep thinking that it might be better to just rewrite parts of it.

 

Oooh..  I just looked at the code for the one you posted and it does serialization as well.  Awesome!  Thanks again.




#43531 Lightweight JSON parser

Posted by Dave M. on 16 January 2013 - 02:36 PM in Project Showcase

Hi everyone, just wondering if there is a status update on this project. I was looking around for a JSON parser for the N+2 and this is only one of two projects that I have found so far. I have confirmed that the latest code available fails all of the tests. Because it still looks like Fabien doesn't have time to fix the parser, I started to work on it yesterday. I am making some progress, but while I understand exactly what Fabien's design intends to do, there are little gotchas here and there that trip me up. Besides saying "thank you" for providing us with the code, I have to say "THANK YOU" for providing unit tests with this project, Fabien. :) That's the only way I'll be able to verify that things are working. So far, I have the first two unit tests working. I'm now ironing out problems with the serializing of arrays of strings in the third test case. And one of the outstanding issues is that my modifications to the Find() method that has the ArrayList outparam unintentionally made it output an ArrayList of JSONObjects and not Hashtable, so I temporarily changed the unit tests to take this into account by casting in the loop.



#43500 Netduino Plus Socket Server Help

Posted by Dave M. on 15 January 2013 - 10:49 PM in Netduino Plus 2 (and Netduino Plus 1)

Can anyone comment on nakchak's comment regarding the usage of events for connections / disconnections?  While I'd love to do that, I've gone through the API reference and used Intellisense to peek at the members, and it sure looks to me like Poll is the only way to get incoming data.




#41449 Open source Amulet touchscreen project for Netduino

Posted by Dave M. on 12 December 2012 - 10:07 PM in Netduino 2 (and Netduino 1)

Hi everyone,

I've been looking for an excuse to use my Amulet touchscreen, and when the N+2 came out, I figured I'd work on it. I decided early on to make this a learning exercise for me with the Amulet, N+2, and git. I have a public project hosted on github that *should* make it really simple to interface with the touchscreen, as it deals with the protocol details for you.

If you want to see what the Amulet is all about, check out GEMstudio at their website. There's a free trial and it emulates the hardware so you don't actually have to spend any money.

No, I don't work for them. :) It's just a cool product that allows you to quickly get a nice UI on your embedded product without having to deal with drawing graphics and handling input events yourself.

Anyhow, hopefully this project is of use to someone out there in the Netduino community besides me. :) I welcome any feedback you might have to make the library better. It's not 100% complete, but what's there should be very useful for most projects.

Amulet.NETMF on Github



#41086 static bool

Posted by Dave M. on 06 December 2012 - 04:59 AM in Netduino 2 (and Netduino 1)

I think you missed the last line inside the loop since you tried to assign a bool to a delegate :P


haha!! You are correct, I *completely* missed that line. Guess I should have written this in the compiler before posting. :)



#41065 static bool

Posted by Dave M. on 06 December 2012 - 01:01 AM in Netduino 2 (and Netduino 1)

or +verbose:

public static void Method_6()
        {
            while (phcontroller.Read()==true && method_state_6 == true)
            {
                ph.Write(false);
                Thread.Sleep(1 * SecondMs);
                ph.Write(true);
                Thread.Sleep(5 * MinuteMs);

            }
}

or ++(really unnecessary)verbose:
public static void Method_6()
        {
            bool phState = phcontroller.Read();
            while (phState == true && method_state_6 == true)
            {
                ph.Write(false);
                Thread.Sleep(1 * SecondMs);
                ph.Write(true);
                Thread.Sleep(5 * MinuteMs);
                phState = phcontroller.Read();
            }
}


These two methods are not equivalent. The last one only Reads once. Did you mean something like this instead, which is definitely way too verbose?

public static delegate bool PhStateDelegate();

public static bool CheckPhState()
{
    return phcontroller.Read();
}

public static void Method_6()
{
    PhStateDelegate phState = CheckPhState;

    while (phState() == true && method_state_6 == true)
            {
                ph.Write(false);
                Thread.Sleep(1 * SecondMs);
                ph.Write(true);
                Thread.Sleep(5 * MinuteMs);
                phState = phcontroller.Read();
            }
}



#41064 I give up here

Posted by Dave M. on 06 December 2012 - 12:46 AM in Netduino 2 (and Netduino 1)

I agree with Lunddahl, but as a simpler test first, you can use
System.Threading.Thread.Sleep( 20)
to wait 20ms after you detect contact. After the 20ms elapsed, check again. If it's still making contact, then proceed. Otherwise, bail out and start over, or poll the next relay.



#41063 General rules for CLR / firmware compatibility?

Posted by Dave M. on 06 December 2012 - 12:34 AM in Netduino Plus 2 (and Netduino Plus 1)

Got the Netduino to work. Since I'm not (yet) using any of the ethernet capabilities of the N+ and N+2, for now I have removed the assembly references to SecretLabs.NETMF.Hardware and SecretLabs.NETMF.Hardware.Netduino. That said, why would adding those references cause the Netduino to not boot correctly, even if I'm not using any of the classes in those namespaces?



#41062 General rules for CLR / firmware compatibility?

Posted by Dave M. on 05 December 2012 - 11:56 PM in Netduino Plus 2 (and Netduino Plus 1)

Awesome, I figured it out. Apparently, the breadboard's power cable came out a little. While the N+ doesn't need this power to run, I do need it to power the MAX232 chip. So having an unpowered MAX232 seems to have wreaked havoc on the behavior of the N+. This didn't solve my problem with the standard Netduino, so I'll start looking at that next.



#41060 General rules for CLR / firmware compatibility?

Posted by Dave M. on 05 December 2012 - 11:45 PM in Netduino Plus 2 (and Netduino Plus 1)

I decided to try out my Netduino as well, since I have one of those here at home. I updated the firmware to 4.2.0.1, and the behavior is different. The first time I ran it, it froze when attempting to create the SerialPort. All subsequent attempts have failed, where VS2010 is frozen when saying that the device is "rebooting...". I have unplugged and reconnected the Netduino after each attempt, just to prevent BSODs. Weird!



#41058 General rules for CLR / firmware compatibility?

Posted by Dave M. on 05 December 2012 - 11:11 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Dave,


Yes, Netduino Plus can use SerialPort without issues. As long as you have enough RAM available. If you create a single-line application with just that line...do you still get the error?

Also...which port is 'port'?

Chris


It seems to vary from run to run. Sometimes I get the error when I create the port. Other times, the error comes up after the creation. And even if the program keeps running (i.e. VS2010 doesn't crash first), the behavior is odd. My serial data event handler usually captures data very, very slowly.

Here's some test code I'm running right now:

Debug.Print( "creating serial port");
_port = new SerialPort( port, baudrate, Parity.None, 8, StopBits.One);
Debug.Print( "setting serial port read timeout");
_port.ReadTimeout = 100;
Debug.Print( "opening serial port");
_port.Open();
Debug.Print( "flushing serial port buffer");
_port.Flush();
Debug.Print( "registering serial port data event handler");
_port.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);            
Debug.Print( "RAM left: " + Debug.GC( true) + " bytes");

The amount of RAM left is always 21300 bytes. "port" is "COM1", and baudrate is 115200.




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.