assurance-tunnel
assurance-tunnel
assurance-tunnel
assurance-tunnel

String to Bitfield



  • Hi there!

    I am struggling and trying to parse ASCII letter to bit field presentation. I am trying to use "Text Parser" actor with no luck.
    I have managed to parse text "!6DF8A1" and extract the 4th character. 
    But howto convert letter 'F' to bit field 1111b. Or a letter 'A' to bitfield 1010b and how to get access to those bits. 


  • Hello,
    Best way would be javascript actor, here is the code

    function main() 
        { 
           var text = arguments[0];//input of text 
           text = text.charCodeAt(5);//fifth character ASCII value (decimal) 
           text = text.toString(2);//binary value 
           text = text + "b";//add b 
           return text;//output the text 
        } 

    And the izzy patch. (but binary for A is not 1010b, is 10000001b!) 5400e5-capture-decran-2016-01-20-a-09.38.28.png 2af459-texttobinary.izz



  • Hi again,

    This was my first posted problem and I am impressed by the speed of comment and views.

    I was a bit unclear when I stated that the letter 'F' should be conversed. Instead I meant hex 'F' should be conversed. That letter contains sensor information of 4 digital channels. Here is the picture of hex 'A':

    PS.
    I really should learn that javascript :)

    f58282-bitproblem.jpg



  • @jhoepffner,

    attached is an old school approach
    from what i understood the string you get is a combination of hex values and each 0-F is representing a word
    to have a good overview about characters / hex values and bits i would suggest [MacASCII Display](http://www.synergycreations.com/downloads.html) a really nice little tool.

    8973c2-hex2bits.izz



  • Hello,
    I need to be more specific…
    Here is a patch and script doing the task

    function main()
    {
    	var out = [];//list declaration
    	var text = arguments[0];//input of text
    	var first = arguments[1];//first letter
    	var last = arguments[2]+1;//last letter
    	text = text.slice(first,last);//choosed letters
    	out[0] = text;//plain output
    	text = parseInt(text,16);
    	out[1] = text;//dec value
    	text = text.toString(2);
    	out[2] = text;//bi value
    	return out;//output the values
    }
    

    49da5b-capture-decran-2016-01-20-a-14.11.20.png b7741a-texttobinary.izz



  • @m-theateer

    Thank you for your help, but javascript is so more elegant, compact and easy to manage.
    jacques


  • @jhoepffner,

    jep js is a big thing, but as you mentioned in the other post, the actors has to grow with the new processing possibilities (midi, tcp send )
    attached you will find a short test in js
    -
    p.s
    just saw your 2nd version this is great

    fde0e6-js_hex2bits.izz


  • Tech Staff

    I also like JS. Its just so easy to understand.. and flexible.

    However, the native actors will be faster. In cases where you are parsing fast data streams (high baud serial connections etc...)
    the native actors are going to eat up less cpu.
    Probably not going to be a common issue, but worth noting for extreme cases.


  • Hi again, 
    Problem solved and love them both! Js and original worked both. Yes there is old school approach doing interactive spaces :)
    I have rs485 network for reliability reasons. I use cheap industrial ADAM modules for polling digital IO. I made a speed test with max 115200 baud. New query was sent immediately after receiving acknowledge message from the IO module. I managed to get 110 query-response in a 1 second with Isadora traditional max 240 cycles. That means 70 digital sensors with polling interval 0.05s.
    Here is the test rig:

    48c267-img_4059.jpg


Log in to reply
 

Looks like your connection to TroikaTronix Community Forum was lost, please wait while we try to reconnect.