-
Okay, it's been a while, I have been busy forgotten, come back to this now...
I found my other board, it works fine with one of the cables. I've managed to update the bootloader on there, and the other board is now being recognised but it will not flash, and I can't type into the REPL/Console...
In the console when plugged in this text appears...
Connected
Loading 11098 bytes from flash...
ho(0); 14:35:23","GIT_COMMIT":"0671a2d91de45a0e05c4b2b385264cf2ef16e463","BOARD":"ESPRUINOBOARD","CHIP":"STM32F103RCT6","CHIP_FAMILY":"STM32F1","FLASH":262144,"RAM":49152,"SERIAL":"34ffdd05-42573838-33692143","CONSOLE":"USB","EXPORTS":{"jsvLock":175045,"jsvLockAgainSafe":175033,"jsvUnLock":175009,"jsvSkipName":81269,"j:21701,"jsvMathsOpSkipNames":23465,"jsvNewFromFloat":77665,"jsvNewFromInteger":77701,"jsvNewFromString":176305,"jsvNewFromBool":77685,"jsvGetFloat":81509,"jsvGetInteger":80673,"jsvGetBool":81773,"jspeiFindInScopes":50889,"jspReplaceWith":19589,"jspeFunctionCall":54541,"jspGetNamedVariable":50941,"jspGetNamedField":52089,"jspGetVarNamedField":51761,"jsvNewWithFlags":175189}}=undefined
And I cannot type, and even when I now can get it into what I presume is DFU mode with the pulsing blue light, it will not update on this one board.
-
-
-
-
I've just updated my perfectly working board to this because the IDE advised it, and then used save() to flash the code I wrote to the board, and now the board is no longer showing up in the USB list on the IDE and when I use various cables to get into bootloader mode I get a blue solid and red light which occasionally pulses blue then goes red and blue solid and bright...
I really don't know what is wrong or what to do, there is no record of this issue happening before, but I am really up s*** creek right now.
-
I was using this but it doesn't work for some reason... it says:
Uncaught Error: Field or method "set" does not already exist, and can't create it on undefined at line 3 col 12...
Specifically this doesn't exist inside that DMX.prototype.newData function, or indeed inside any other than the first one DMX()...
I also don't know what you mean about bind, but I tried adding this and it also didn't work.
-
I've been working on creating a module for DMX... Not done this before, how does this stack up?
var exports = {}; function DMX( serial, interrupt ) { this.data = new Uint8Array( 512 ); this.id = 0; this.serial = serial; this.interrupt = interrupt; // Setup serial port this.serial.setup( 250000 ); this.serial.on( 'data', this.newData ); // Listeners this.dataListeners = []; this.channelListeners = {}; // Listen for the interrupt pin to drop setWatch( this.newFrame, this.interrupt, { repeat: true, edge: 'falling' } ); } // Handle new bytes of data as they come in DMX.prototype.newData = function( d ) { // Store the bytes received at the buffer index DMX.data.set( d, DMX.id ); // Move the buffer index along. DMX.id += d.length; }; // Send out notifications to all event listeners when frame is complete. DMX.prototype.newFrame = function() { // Reset the byte buffer index to 0 for the next frame of data. DMX.id = 0; // Itterate through all the registered data listeners and send them the data for ( var i in DMX.dataListeners ) DMX.dataListeners[i]( DMX.data ); // Itterate through all the registered channel listeners and send them their channel values for ( var ch in DMX.channelListeners ) for ( var j in DMX.channelListeners[ch] ) DMX.channelListeners[ch][j]( DMX.data[ ch ] ); }; // Handle registration to event notifications DMX.prototype.on = function( type, handler ) { // If data listener: push function onto array if ( type == 'data' ) DMX.dataListeners.push( handler ); // If channel listener if ( type >= 1 && type <= 512 ) { // Check channel for existing listeners if ( DMX.channelListeners[type] !== undefined ) { // Push additional listener onto array DMX.channelListeners[type].push( handler ); } else { // Otherwise: create new array with listener in it DMX.channelListeners[type] = [ handler ]; } } }; // Export the module exports.connect = function( serial, interrupt ) { return new DMX( serial, interrupt ); }; /////////////// var DMX = exports.connect( Serial2, B9 ); // Listen for changes on channel 1 DMX.on( 1, function( val ) { analogWrite( LED1, val / 255, { forceSoft: true } ); } ); // Listen for changes on channel 2 DMX.on( 2, function( val ) { analogWrite( LED2, val / 255, { forceSoft: true } ); } ); // Listen for changes on channel 3 DMX.on( 3, function( val ) { analogWrite( LED3, val / 255, { forceSoft: true } ); } ); // Listen for full frames of data DMX.on( 'data', function( data ) { // console.log( data ); } );
-
-
After a bit further experimentation I was able to so far verify the data works fine all the way up to channel 36 which is as far as I can go...
This is an amazing result... I didn't think it would work, let alone be this easy, next I need to wrap it up in a more user friendly way, however I couldn't resist tying it into the three LEDs on the board for a test...
https://www.youtube.com/watch?v=29v4xd3UCLA
Code:
var dmx = new Uint8Array( 512 ); var dmxIdx = 0; Serial2.setup( 250000 ); Serial2.on( 'data', function( d ) { dmx.set( d, dmxIdx ); dmxIdx += d.length; } ); setWatch( function() { dmxFrame( dmx ); dmxIdx = 0; }, B8, { repeat: true, edge: 'falling' } ); function dmxFrame( data ) { analogWrite( LED1, data[1]/256, { forceSoft: true } ); analogWrite( LED2, data[2]/256, { forceSoft: true } ); analogWrite( LED3, data[3]/256, { forceSoft: true } ); // console.log( "1: " + data[1] + " 2: " + data[2] + " 3: " + data[3] + " 4: " + data[4] + " 5: " + data[5] + " 6: " + data[6] ); // console.log( "7: " + data[7] + " 8: " + data[8] + " 9: " + data[9] + " 10: " + data[10] + " 11: " + data[11] + " 12: " + data[12] ); // console.log( "13: " + data[13] + " 14: " + data[14] + " 15: " + data[15] + " 16: " + data[16] + " 17: " + data[17] + " 18: " + data[18] ); // console.log( "19: " + data[19] + " 20: " + data[20] + " 21: " + data[21] + " 22: " + data[22] + " 23: " + data[23] + " 24: " + data[24] ); // console.log( "25: " + data[25] + " 26: " + data[26] + " 27: " + data[27] + " 28: " + data[28] + " 29: " + data[29] + " 30: " + data[30] ); // console.log( "31: " + data[31] + " 32: " + data[32] + " 33: " + data[33] + " 34: " + data[34] + " 35: " + data[35] + " 36: " + data[36] ); }
-
With this code it kind of works...
var dmx = new Uint8Array( 512 ); var dmxIdx = 0; Serial2.setup( 250000 ); Serial2.on( 'data', function( d ) { dmx.set( d, dmxIdx ); dmxIdx += d.length; } ); setWatch( function() { dmxFrame( dmx ); dmxIdx = 0; }, B8, { repeat: true, edge: 'falling' } ); function dmxFrame( data ) { console.log( "1: " + data[1] + " 2: " + data[2] + " 3: " + data[3] + " 4: " + data[4] + " 5: " + data[5] + " 6: " + data[6] ); }
However the issue is that bytes later on seem to become corrupt if the values before it are low... I looked at the signal out of the DMX shield and it looks like the signal was jumping around a bit only when the circuit with the diode, capacitor and resistor were connected.
My theory was that perhaps there was some electricity flowing back through the resistor or because it's a general purpose diode it is some how not quick enough. I remember that zener diode is faster or something.. anyways my electrical knowledge is limited here so I found a little zener and tried it and it's working great.
It appears to be a 1n2268.
More experimenting to happen...
-
I just tried a 0.1uF and that is much better, also got a 10KΩ Potentiometer there to get the right value... turns out that 1KΩ is right... I wonder if that was a type in your original post?
Anyways, I swapped back in the 1KΩ resistor and it's got a nice little pulse just at the end of that long initial break but no where else...
You can see on channel 1 there is lots of toing and froing but the only time it's enough to drop below 1V is the break at the start. The dotted line horizontal line represents 0V and the parallel one just above in solid is the 1V threshold.
Next is to try looking at the code in Espruino to get the interrupt working.
FYI: For those curious the scope is a Rigol MSO1074Z... It's the same as the DSO1054Z series but it has a built in logic analyser and a signal generator.
I've used an analog scope before and that was revolutionary from not having one. Then getting a digital scope was another wow moment... Having access to a scope with build in Logic Analyser is mind bogglingly useful, in a way I never appreciated until I needed to get that red blip.
IT's been a great project for learning!
-
I've had a go at this today, I have been experimenting with your explanation of the circuit...
So this is the result...
The white crocodile clip is the decoded DMX data from the shield. Through a 1n4001 diode into a 1uF capacitor, and a 1KΩ resistor to ground.
This is the result on the scope...
D0: Data– going into DMX Shield.
D1: Data+ going into the DMX Shield.
D2: Is the Logic analysers reading of the interrupt output.
1: Is the same as D2 but on the scope. You can see the signal drops to close to 1V but only after the entire packet.The particular DMX board I am using is a Chauvet Obey 6 which appears to be controlling 6 faders on 6 pages/fixtures... i.e. 36 channels only at the moment.
I am going to play about with the values now but I am not sure what I am really doing. I think probably a smaller capacitor as the drop off is long... maybe 0.1uF.
If you see this and have a bright idea I am going to be at my desk for an hour or two with the setup to see if I can get below 1V at the start of the data. However I am not sure what the start is...
The signal goes low for a long period, then high, and low again for a short period (is there a channel 0?) then the bits can clearly be seen with a short break between each...
-
I am also trying to do this for a project quite urgently, I was trying to use Arduino but the example code out there just doesn't work... I really don't know where to start... I have hardly used Espruino before so I am a bit lost...
I managed to get it reading from an SD card dispite the error on the tutorial page, and I am about to try hooking up an Arduino DMX shield to the Esprino...
I bought the SKPang one: http://skpang.co.uk/catalog/arduino-dmx-shield-p-663.html
I am not really sure what to do next, I guess I will try receiving DMX data, but I am not sure what to do about the so called framing error... I don't really understand how you could possibly deal with that issue...
I could really use some help here...
Basically I am trying to receive DMX data from a industrial DMX board so it could be transmitting up to the full 512 channels, I am hoping I can do some kind of DMX.on('1', function( val ) { //do something } ); type of thing as I am aiming to listen to some channels of data, look up something I have read into memory from an SD card, and then send a RS-485 response back out another USART to another device.
All help greatly appreciated.
I am not sure if you are aware but Persona is being shut down on the 30th November:
https://developer.mozilla.org/en-US/Persona