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.

<Jeremy>'s Content

There have been 31 items by <Jeremy> (Search limited from 29-April 23)


By content type

See this member's


Sort by                Order  

#17836 Working with UART

Posted by <Jeremy> on 10 September 2011 - 06:17 PM in Visual Studio

Hi magarcan

I've been having a look at the problem you've described (since I've been working on some serial port things myself).

First, I'm assuming you've got D0 (COM1 Rx) connected to D3 (COM2 Tx), and D1 (COM1 Tx) connected to D2 (COM2 Rx) here.

Given that, if you look in the SerialPortHelper.cs class, the serialPort variable is declared as static (as are buffer and
bufferlength). I think what's happening is that since you've instantiated two separate ports in your class, you're actually sharing
resources between them. So when an event is fired to say "data has been written to COM1", the code reacts to that event
by trying to read from COM2. If you leave the serialPort variable as static, and change the serialPort_DataReceived
method to look like the code below, you'll see what i mean:

private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    // i expect these to both return the same port
    // if serial port is static, i find they're different.
    Debug.Print("serial port name = " + serialPort.PortName);
    Debug.Print("sender name = " + ((SerialPort)sender).PortName);
    lock (buffer)
    {
        if (serialPort.BytesToRead > 0)
        {
            int bytesReceived = serialPort.Read(buffer, bufferLength, bufferMax - bufferLength);

            if (bytesReceived > 0)
            {
                bufferLength += bytesReceived;
                if (bufferLength >= bufferMax)
                    throw new ApplicationException("Buffer Overflow.  Send shorter lines, or increase lineBufferMax.");
            }
        }
    }
}

So basically I think if you use the method above, and remove the static modifier from the serialPort variable, you
should make some progress. You might want to remove static from the other two member variables too.

I guess you'll also have noticed I added a little bit to that code to check if there's at least one byte to read from serialPort.
Stepping through your program slowly in debug mode gives me different behaviour to when I just run it
without breakpoints - I found there was an exception in this method because whereas we've been notified that data has
been received, when I actually look at the serialPort.BytesToRead property I find that there's nothing there. I couldn't
work out why the event was being fired, if you have an answer I would be really interested to know!

But this looks like a great library, it's interesting to me as well.

I hope this helps - let me know how it works out.

Jeremy



#32239 This looks like a bug in InterruptPort

Posted by <Jeremy> on 18 July 2012 - 10:56 PM in General Discussion

Hi BitFlipper Could you confirm if the fix in .NET MF4.2 for issue 1073 (http://netmf.codeple...m/workitem/1073) actually solved the problem for you? I'm coming across a similar InterruptPort issue myself and just wanted to check if your issue was resolved by the change. Thanks! Jeremy



#32272 This looks like a bug in InterruptPort

Posted by <Jeremy> on 19 July 2012 - 09:08 AM in General Discussion

Hi BitFlipper - thanks for replying, that's useful information anyway. My issue sounds possibly related to yours. I've a sensor sending 43 bits of information, and the Netduino only picks up around 30-40 - I've found that it "loses" interrupts in the middle of the signal. I'll keep looking for a solution :) Thanks again, Jeremy



#18033 Sockets

Posted by <Jeremy> on 15 September 2011 - 07:52 AM in Netduino 2 (and Netduino 1)

Hi there CoolComponents is the supplier I use - I've found they're very quick to deliver any time I've used them. Are these the components you mean? http://www.coolcompo...products_id=348 http://www.coolcompo...products_id=347 I hope this helps - they're probably best if you're based in Europe, if you're somewhere else I'm sure another person on the forum can recommend a supplier :) Cheers, Jeremy



#17784 Reading data chunks from a COM port question

Posted by <Jeremy> on 08 September 2011 - 10:14 PM in Netduino 2 (and Netduino 1)

Hey Stefan and Liqdfire Thank you for the assists - it sounds like the answer for me is to develop a custom solution, like you say maybe have a unique "end of packet" sequence. Liqdfire - If you do get a chance to post some code that would be really great - in the meantime, I'll spend a bit of time coding up a solution and post my code when I'm done. Hopefully this thread will help someone else out if they hit the same problem. Thanks again, Jeremy



#17758 Reading data chunks from a COM port question

Posted by <Jeremy> on 08 September 2011 - 01:58 PM in Netduino 2 (and Netduino 1)

Hi everybody I've got a question about Serial port communication using the netduino. This is the first time I've built something like this - my first week with a Netduino - but I hope this isn't a dumb question!!!. Where I've got to so far: I'm using a barebone FTDI USB to Serial mini adapter - I open COM1 at 115200, and repeatedly send a byte array (each packet being 16 bytes long) from my netduino. I also have a C# client application which reads from the com port at 115200, and successfully sees the stream of bytes that I'm sending from the netduino. So far so good. Where I'm hitting the problem: The client application isn't able to determine where my packets of 16 bytes start and end. I mean if I tell the my client app to read 16 bytes from the port, I find that it's possible it'll pick up the last 7 bytes of one packet and then the first 9 bytes of the second. I think this is probably expected behaviour. My current workaround is a bit of code that looks for a certain byte pattern in what comes in from COM1 - when it finds that, then read the next 16 bytes of data and assume it's a valid packet of my data - and I just repeat that. But do you guys know if there's a more elegant or robust solution to my problem, or if there's a protocol I should look into using to tokenise my data stream? Thanks in advance for any help! Jeremy



#17851 Reading data chunks from a COM port question

Posted by <Jeremy> on 11 September 2011 - 11:39 AM in Netduino 2 (and Netduino 1)

Hey liqdfire and Mario Thank you so much for this help and information - I've been getting through it this weekend and think I've got a better (and more object oriented) solution to my problem with your help. Thanks again, Jeremy



#18810 PCB

Posted by <Jeremy> on 05 October 2011 - 08:16 AM in General Discussion

Hey Baxter - thanks for those links. That PCB in a box looks like exactly what I need to start off at home. Now I just need to improve my soldering and I can build some nice shields...:) Thanks again Jeremy



#18766 PCB

Posted by <Jeremy> on 04 October 2011 - 01:01 PM in General Discussion

Hey everyone Does anyone have any advice or recommendations on how to get started with some PCB manufacture at home? I'm looking for kit that's pretty small scale, the sort of thing you can do in an apartment on a table. If any of you can recommend a good and reasonably priced product, I'd really appreciate it! Thanks in advance, Jeremy



#18035 Netduino Plus + ID-20 (again!)

Posted by <Jeremy> on 15 September 2011 - 08:08 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Jace I don't know this component, but I saw this tutorial for the arduino and your component which might be useful (sometimes I find comparing the arduino and netduino implementations useful when I hit a problem). http://bildr.org/2011/02/rfid-arduino/ The first thing that jumped out at me was that your pins are connected similarly to the arduino except for one - you mention that you have Pin 2 connected to netduino 5V, but the arduino has Pin 2 connected to netduino Pin 13. EDIT: I guess you have configured the pins that way to make sure you do just one read so my observation might not help you too much :( But I hope this is something to look into anyway! Cheers, Jeremy



#32410 Netduino Firmware v4.2.0 RC5 (Netduino + Netduino Plus)

Posted by <Jeremy> on 21 July 2012 - 09:56 AM in Beta Firmware and Drivers

Is there anywhere I can download the source for this firmware? I've seen a couple of other people post this question but I haven't seen an answer. Or is the firmware source not going to be released until it goes gold? Thanks Jeremy



#32432 Netduino Firmware v4.2.0 RC5 (Netduino + Netduino Plus)

Posted by <Jeremy> on 21 July 2012 - 06:26 PM in Beta Firmware and Drivers

Thanks Chris, that's great. Jeremy



#18153 My first project with netduino

Posted by <Jeremy> on 18 September 2011 - 07:23 PM in Project Showcase

Hey Hackaroth Very nice! I've been toying with the idea of buying one of these and I think you've convinced me :) Jeremy



#32863 Increasing the resolution of the system timer

Posted by <Jeremy> on 29 July 2012 - 12:27 AM in Beta Firmware and Drivers

Hi again - no luck with the DHT11 after increasing my firmware resolution I'm afraid. My firmware is definitely now running at 375kHz, and the Netduino doesn't seem to be distinctly seeing all 43 pulses for each temperature/humidity reading (usually half that or less). Oh well. (This is of course just on my system - other people's mileage may vary.)



#32361 Increasing the resolution of the system timer

Posted by <Jeremy> on 20 July 2012 - 03:18 PM in Beta Firmware and Drivers

Hi there I've built this firmware with the changes to the 'slow clock' time, but I'm not seeing any improvement in performance in my DHT11. Is there a command to query the Netduino properties to find the slow clock time? I just want to check that my new binaries actually have this change built into them. Thanks, Jeremy



#32859 Increasing the resolution of the system timer

Posted by <Jeremy> on 28 July 2012 - 11:31 PM in Beta Firmware and Drivers

Hi CW2 - thanks for this, I just saw this reply, sorry for not replying sooner! I'll try it and let you know how I get on, Jeremy



#21554 HMC5883L Magnetometer Netduino Code

Posted by <Jeremy> on 10 December 2011 - 06:10 PM in Project Showcase

Hey willgeorge No problems at all! I'm really glad you were able to use it :) Jeremy



#18015 HMC5883L Magnetometer Netduino Code

Posted by <Jeremy> on 14 September 2011 - 09:54 PM in Project Showcase

Hey everyone I just bought a HMC588CL magnetometer, and after a bit of googling I haven't found any records of existing Netduino code for getting started with it. So since I've got mine working, I've attached my code. Let me know if there's any bugs in my code, but hopefully not - you'll see that it's very simple code - the application doesn't really do anything except output the X and Y readings, but it gets you started with the device. You can use these readings to calculate your bearing from North. I hope someone out there in the community finds a use for it in a project! Cheers, Jeremy

Attached Files




#18809 Help porting Arduino code for FM radio module

Posted by <Jeremy> on 05 October 2011 - 07:41 AM in General Discussion

Hi Ken A4 and A5 are the pins for I2C - there's a great post here http://forums.netdui...5-pinout-cards/ I have the netduino plus card printed out and refer to it pretty much every day :) Jeremy



#18853 Help porting Arduino code for FM radio module

Posted by <Jeremy> on 06 October 2011 - 10:20 AM in General Discussion

Hey Ken Well done, and 54 out of 75 is higher than anything I got out in the wilds of the countryside! What I found with the RDS was that I had to tell the device to listen for it for a while. I've written some proof of concept code for it, but as I said before it's a bit of a tangled mess, but it definitely gets text out of the signal. I'll look at the code again this weekend and have a go at tidying it up - but as I remember, the process is: 1. Look at the RDS bit after tuning to a strong channel - keep polling until it until it indicates there's RDS data. 2. When it finds there is RDS data, look at the RDSA, RDSB, RDSC and RDSD registers (details are in data sheet). 3. First look at the RDSA register, shift by 11 bits, if it equals 0 or 1 then it's the station name, if it's 5 or 6 then it's the station information. 4. If you're looking at the station information, then look at the values of the RDSD register - split the dataword into two bytes, convert each from a byte to corresponding ascii character. 5. If you're looking at the station information, then look at the values of the RDSC and RDSD register - split the two datawords into four bytes, convert each from a byte to corresponding ascii character. 6. Build up consecutive letters to make up the station name and information. I've found that station name only ever has 8 characters, station information has many more. I imagine you'll actually have it cracked by this weekend anyway, let me know if you do, but if not I'll try to help out. Hope this is helpful, Jeremy



#18765 Help porting Arduino code for FM radio module

Posted by <Jeremy> on 04 October 2011 - 12:58 PM in General Discussion

Hi Ken, I've done this with the Netduino already - the tricky part is that you need to do a little manipulation with the array you use to read and write to the registers, I think that when you start reading the first word that comes out is at 0x0A rather than 0x00. But porting from Arduino to Netduino is definitely possible. If you're interested I'll try to resurrect the code from my development machine, just let me know. Jeremy



#18815 Help porting Arduino code for FM radio module

Posted by <Jeremy> on 05 October 2011 - 10:52 AM in General Discussion

Yeah that's a good question, I think that A5 is a clock pulse so it's not analogue. I think the A4 (SDIO) sends logic pulses, rather than a clock signal. But it's completely possible I'm wrong, there's guys like Stefan, CW2 and Mario (and others too!) who know how to explain it much better than me. I'm watching the forum thread below with interest :) It seems to be very relevant to our discussion! http://forums.netdui...64-i2c-voltage/ Jeremy



#18802 Help porting Arduino code for FM radio module

Posted by <Jeremy> on 04 October 2011 - 09:48 PM in General Discussion

Hey Ken I've attached the 3 files I think you need to get started - I've tried to keep it close to the Arduino code so it's easy to compare the two. Once you've got the Netduino and Si4703 talking, getting the RDS data is pretty easy. If you hit any problems with that, give me a shout, I've got another class that outputs the channel name and description, but it's seriously not pretty code. I have been using the Sparkfun breakout board, here are the pins I used. Vcc - 3v3 GND - Gnd SDIO - A4 SCLK - A5 !SEN - n/c !RST - D2 GPIO1 - n/c GPIO2 - n/c As with any of these sorts of things, works on my hardware, but use at your own risk...:) Let me know how it works out, Jeremy

Attached Files




#18868 Help porting Arduino code for FM radio module

Posted by <Jeremy> on 06 October 2011 - 12:32 PM in General Discussion

Hi Ken To be honest, everything you've put in the last post pretty much covered I've got at home on RDS. Certainly I think your code looks ok - I've found that some channels initially report 'No RDS', but if I poll for a few seconds like in the Arduino code, the RDS comes up. Have you tried polling, say for 60 seconds to see if anything appears in the RDS registers? Jeremy



#19056 Help porting Arduino code for FM radio module

Posted by <Jeremy> on 11 October 2011 - 10:55 PM in General Discussion

You've got me interested in this breakout board again, I think we can improve the Programme Service Name code a little - in the PrintRadioName method, I put the RDSB value and text into a DictionaryEntry object, but I think it would be better to store

( (this.Si4703_Registers[RDSB] & 0x00FF) & 0x3) * 2;

So this time, each of the pairs of letters will be associated with the numbers 0, 2, 4, and 6, and therefore you can determine the correct order of the letters and what letters come first.

Jeremy




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.