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.

Luke Cummings's Content

There have been 38 items by Luke Cummings (Search limited from 08-June 23)


By content type

See this member's


Sort by                Order  

#9280 Netduino + BL-CTRL 2.0 + I2C = Not working?

Posted by Luke Cummings on 10 February 2011 - 09:11 PM in Netduino 2 (and Netduino 1)

The fist thing that jumps out is you specified address 2 and 3 in you post, but 0x29 in your code. If the address is supposed to be 2 then cahnge the first line to : I2CDevice i2c = new I2CDevice(new I2CDevice.Configuration(0x02, 100));



#9749 while(true)

Posted by Luke Cummings on 18 February 2011 - 07:07 AM in General Discussion

There is another way to grab execution without requiring the checking of a while, try this:
for(;;);

It looks funny but if you think about how a for loop works you can see how this basically turns into a looping nop instruction.

That said since you are dealing with an interpreted language I'm not sure if this would actually turn into an infinitely looping nop instruction like it would in c.


This makes it so that other threads may be delayed in getting access to processor time giving you a slow response and also doesn't let the chip go into a power saving mode.


It shouldn't delay any other threads as the processor is always doing "something" nop's or otherwise, but you're correct that it will increase power consumption.

Edit: This statement is unverifiably vauge



#10300 Simultaneous Outport Ports?

Posted by Luke Cummings on 27 February 2011 - 07:03 AM in Netduino Plus 2 (and Netduino Plus 1)

Wow Corey, I just has a "Duh" moment there... I guess some of us hardware guys have been spending a little too much time in .Net! :) Great explaination!



#10095 Simultaneous Outport Ports?

Posted by Luke Cummings on 24 February 2011 - 06:22 PM in Netduino Plus 2 (and Netduino Plus 1)

Sounds like your problem is a hardware related issue, can you be more specific as to what you are trying to do? Currently your saying these two pins will always have the same value. If so just use one pin.



#12507 Locking Cat Feeder

Posted by Luke Cummings on 26 April 2011 - 06:57 PM in Project Showcase

Any variable voltage (IE, not 3.3V OR 0V inclusive) needs to be measured through an analog pin. You may need to use a voltage divider to drop the voltage to a level between 0V and 3.3V. Look for a voltage divider calculator to find the correct values of the 2 resistors.

Please note, if you are tapping off a motor lead like that, you may need to use some form of circuit protection. Motors are noisy and may wreck havoc on the Netduino if the sampling circuit is not correctly done.


The netduino's MCU AT91SAM7X512 pins are 5V tolerant so even though they only output 3.3V they can handle up to 5V as an input, that being said I wouldn't let the netduino look at an inductive load like chris says. Your just asking for trouble. Instead I would recommend prying open the control board to look for a digital signal (5V or less) that represents the motor action. To do this you will need a multimeter, just trigger the motors and start probing around for the signal.

Cheers!



#8642 Coding style discussion

Posted by Luke Cummings on 28 January 2011 - 11:08 PM in General Discussion

Brandon, I think you're reading my comments in the wrong tone - i meant them as a general comment, not targeted at anyone specific. I'm an Aussie, we're pretty layed back and chill - if in doubt, just read my post as a layed back view point :)

Please feel free to take a look at these links:
IDesign have an exceptional coding standard for C#, which a lot of companies I know of base their standards on. These are basically an expansion of Microsoft's:
http://www.idesign.n...ng Standard.zip - zip with PDF.


This is what Microsoft use internally: http://blogs.msdn.co.../26/361363.aspx

The guideline for creating class libraries is a rather informative read: http://msdn.microsof...y/ms229042.aspx

And this is the book I mentioned (which I recommend every developer - professional, amatuer and enthisuast alike read) - http://www.amazon.com/dp/0321545613/ - on on Book Depository if you're not in the USA (free shipping! woo) http://www.bookdepos...sign-Guidelines



IDesigns C# standards (my personal favourite), section 1 point 4:

Prefix member variables with m_. Use Pascal casing for the rest of a member
variable name following the m_.
public class SomeClass
{
   private int m_Number;
}



#8559 Coding style discussion

Posted by Luke Cummings on 27 January 2011 - 04:07 PM in General Discussion

Move your _coefficients.Length statement to it's own local variable, before you loop and then reference that. It's much faster in netMF than referencing the property.

Also, underscores are against most best practices for .Net :)


Hey Mark, good catch i didn't even notice I did that. Also the _privateMember or m_privateMember is apart of most c# coding standards I've seen.



#9598 ATmega 328p programmer

Posted by Luke Cummings on 15 February 2011 - 10:03 PM in General Discussion

Hi guys,

I am looking for a ATmega 328p programmer. The reason is that my 9dof from Sparkfun has (apparently - what a bummer) a flawed bootloaded and needs to be reflashed.
Thus I am wondering if you have any recommendations (possibly being available in EU).

I guess I'll have to solder SPI pins as well. Just great :blink:


If you already have a spare arduino you can reflash the arduino bootloader like this:
http://arduino.cc/en...rial/ArduinoISP



#10315 Strange Data on SDA/SCL

Posted by Luke Cummings on 27 February 2011 - 05:02 PM in Netduino Plus 2 (and Netduino Plus 1)

I have a BMP085, when I was messing around with it a while ago I mistakenly applied reverse voltage to it, and now it generates very similar data to yours... :mellow:



#10205 Quadcopter Early Flight

Posted by Luke Cummings on 25 February 2011 - 05:04 PM in Project Showcase

Can you offer any details up about your platform?



#8037 I2C Devices using the I2CBus class

Posted by Luke Cummings on 21 January 2011 - 02:09 AM in Project Showcase

I've already touched on this. It can be used by pretty much any I2C device on probably any .NET Micro Framework device.

My work -> A derivative of Pavel Bansky's I2CBus class, but implements the singleton pattern (because it should be implementing the singleton pattern since you are supposed to only have one instance of the I2CDevice class.) You really might want to explore using the singleton pattern so that you guarantee that there is only one instance of the I2CDevice being used by your I2C devices.

I used this in the Bosch BMP085 Digital Pressure and Temperature Sensor

FYI my singleton implementation of the I2CBus class is being used in several projects with as many as four I2C devices on operating on the same bus.


phantom I just finished reworking my quad project to including your I2CBus, works fantastic! I really like this approach, elegant and simple.

Cheers!



#9137 BitConverter

Posted by Luke Cummings on 08 February 2011 - 12:31 AM in Project Showcase

If you are at all concerned with speed and/or the gc, you should try my approach:

When dealing with bit conversions always use the Utility class, for instance working with floats:
public static unsafe float ToFloat(ref byte[] buffer, int offset)
{
   uint value = Utility.ExtractValueFromArray(buffer, offset, 4);
   return *((float*) &value);
}
public static unsafe void ToBytes(ref byte[] buffer, int offset, float value)
{
   Utility.InsertValueIntoArray(buffer, offset, 4, *((uint*) &value));
}

Note that the name ToBytes isn't exactly accurate as normally a bit converter would return the array, but usually you are using this to pack data in a long buffer, and using the reference saves the additional hit for making a new array.

or how about a double word sized variable:
public static long ToLong(ref byte[] buffer, int offset)
{
   long value = (long)Utility.ExtractValueFromArray(buffer, offset, 4) << 32;
   value |= Utility.ExtractValueFromArray(buffer, offset + 4, 4);
   return value;
}
public static void ToBytes(ref byte[] buffer, int offset, long value)
{
   Utility.InsertValueIntoArray(buffer, offset, 4, (uint)(value >> 32));
   Utility.InsertValueIntoArray(buffer, offset + 4, 4, (uint)value);
}

Obviously you could adapt this for any other types you require. These are just what I use in my current project.

Cheers



#21885 Convert byte[4] to float

Posted by Luke Cummings on 19 December 2011 - 10:56 PM in Netduino 2 (and Netduino 1)

Hi Luke,

I'm used to programming in C & C++

...

e.g. is is possible to prevent .Net making changes to the memory in the background during an unsafe function call?

Paul


Paul,

Pointers in C# using the unsafe construct are just as dangerous as in any other case. For example check out how I managed to brick my FEZ panda on this thread: http://www.tinyclr.com/forum/12/2700/. Using pointers gives you unfettered access to any memory you choose.

Really my mistake could have been made whether I was using managed or native code. Once you start getting into more advanced topics, like accessing various chip features (ie IAP on the NXP chip that GHI uses for USBizi) it becomes risky, especially when you know just enough to get yourself in trouble ;)

edit:
@Mario: you are correct about it not being supported, but I've never had an issue using it. In this case my conversions were 3 times faster than anything else I could come up with.

-Luke



#21887 Convert byte[4] to float

Posted by Luke Cummings on 19 December 2011 - 11:11 PM in Netduino 2 (and Netduino 1)

I would hate to drive traffic on a rival site so for fairness, here is the bitconverter class.

Attached Files




#21886 Convert byte[4] to float

Posted by Luke Cummings on 19 December 2011 - 11:08 PM in Netduino 2 (and Netduino 1)

Hi Luke,

I converted your code to a DLL, imported it into Visual Basic and it works like a charm. All other unsafe code I tried trashed my Netduino. Thanks for providing this badly needed functionality.

Baxter


Glad I could help. There definitely are some 'gotchas' using this technique.



#21831 Convert byte[4] to float

Posted by Luke Cummings on 18 December 2011 - 10:17 PM in Netduino 2 (and Netduino 1)

Just for sake of it, here is the code I was using for my quad copter project. Of all my testing this ended up being the fastest. http://code.tinyclr....4/bitconverter/



#10643 Quad.Net Quadrocopter for .NETMF

Posted by Luke Cummings on 07 March 2011 - 05:15 PM in Project Showcase

Hello Brandon

I am interrested by your project, i would like to read your code but i can't access google site and tortoise say "Forbidden
Your client does not have permission to get URL /p/quadnet/ from this server."

it's my fault (bad client or bad actions) or it's because you should give me a read acces before ?

Thanks a lot


Gilles,

Currently the project is not posted but we will be going live soon, the new project site is available at http://dotcopter.net/



#7924 Quad.Net Quadrocopter for .NETMF

Posted by Luke Cummings on 19 January 2011 - 06:46 PM in Project Showcase

I just recently started porting my quad based on Aeroquad to GHI's FEZpanda board. I currently solve my realtime problem by offloading to a arduino ported teensy. I got so excited when I started reading about the possiblility of running native code to handle everything on the one board that I bought a netduino from Sparkfun. Unfortunately its gonna be 3 weeks till it gets here (on backorder). I would be very interested in collaborating on a project such a yours.



#8201 Quad.Net Quadrocopter for .NETMF

Posted by Luke Cummings on 23 January 2011 - 07:45 PM in Project Showcase

Brandon, that is indeed the code running in that video



#8136 Quad.Net Quadrocopter for .NETMF

Posted by Luke Cummings on 23 January 2011 - 03:58 AM in Project Showcase

Brandon, hows the weather over in Van? lol always great to work with the best... I'm working with mecurial right now so I had to get subversion, installing as I type. I was reading the thread you started before on the same topic and I wanted to put the question to bed. Can you fly a quad with NETMF? Hell yes! check this out: As I alluded to previously its not totally .Net as the receiver stuff just isn't possible. But there you go. I agree basing off aeroquad is going to be the way to go, in fact that is what I have base FEZiquad off of. (Don't laugh I needed to call it something) The mecurial repository is available on google code: http://code.google.com/p/feziquad/ Well thats all for now, time to start checking out what you've got so far... Edit: Actually there is one other thing, what is DDD?: this http://www.gnu.org/software/ddd/?



#8534 Quad.Net Quadrocopter for .NETMF

Posted by Luke Cummings on 27 January 2011 - 07:57 AM in Project Showcase

Brandon, you may want to avoid making multiple posts in a row. It makes it very difficult to read the thread.

As for DR&Expo, if you have a computer radio, you can program that in.

I recommend you get a computer radio so you can switch back and forth between multiple DR&Expo settings. I use gentle settings for departure and tighter settings for cruising.


Chris, you may want to avoid being a dbag too many times in a row. It makes it very difficult to read the thread.



#8578 Quad.Net Quadrocopter for .NETMF

Posted by Luke Cummings on 27 January 2011 - 07:08 PM in Project Showcase

While we are on the issue, I was thinking it might be nice to have a cheat sheet with major .Net features, and the performance hits involved. One this that has stood out to me is that the ms code rarely uses properties, relying on public variables instead. It would be nice to develop our own "Best Practices" especially as it relates to pseudo real-time code. One of the major things I seen thrown around a lot is this concept that you can never know how long .Net is going to take to execute any given line. I think with enough understanding we should be able to quantify every line. This is especially important to the success of this project. Just to keep you guys in the loop, I had a major hardware failure (blew out the bearing on a motor) that has stopped me for the moment from trying to fly again. I have every reason to believe that it could have actually flow. I think the only thing that was stopping me from doing so was what Seto and Mark both identified. Seto if you do have a quad that you would be willing to try on .net and an extra MCU I could provide you with the tools to get running on my platform. For that matter if anyone else out there is interested let me know and I will put together an architecture of how it works. That being said I did put in an order for replacement parts this morning, so hopefully i will be back up soon.



#9086 Quad.Net Quadrocopter for .NETMF

Posted by Luke Cummings on 06 February 2011 - 09:35 PM in Project Showcase

A pull-down resistor pulls the output to ground - so, there will be 0% PWM output (logic low) during Netduino startup (when the pin is floating high).


Your missing the point, 0% output is not logic low, 0% output is a pulse lasting 1000 microseconds every 20 milliseconds. Holding the pin low would not do anything.



#8580 Quad.Net Quadrocopter for .NETMF

Posted by Luke Cummings on 27 January 2011 - 07:20 PM in Project Showcase

Oh sorry I was under the impression you had been flying already.



#9089 Quad.Net Quadrocopter for .NETMF

Posted by Luke Cummings on 06 February 2011 - 11:53 PM in Project Showcase

I see - sorry for my misunderstanding.


No problem I didn't mean to be rude in my response. Actually thinking about it though it might be worth a try. I wasn't thinking about the fact that the pins will float during startup, I'm gonna try this anyways it might actually be a solution. Given not what I was thinking of, but I will report back if this works.

Cheers




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.