How long does this take to execute


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Posts
    98


    Did you find this post helpful? Yes | No

    Default Re: How long does this take to execute

    well now you've done it Henrik

    i was just warming up to the idea of doing everything in a polled loop and carefully squeezing activities in

    re DT-Ints when you say "soft timing" do you mean things like counting the number of times through the Main Loop (or sub loop) to create a crude counter / timer ?
    i do that a lot for certain imprecise timing requirements, yeah i know it is not good practice and has many down sides but it is good enough for many things

    or do you mean things like PAUSE and PAUSEus ?
    or both ?

    my plan at the moment is to use 18F25K22 (Charles has been most supportive!) and it will do 64Mhz and does 5V which the '20 does not (big advantage as DMX transceiver i am told must be 5V due to custom and practice even though there are 3.3V RS485 transceiver chips out there)

    as to OSC, the way i read the data sheet i can get 64MHz using 4X PLL either with INTOSC or XTAL at 16MHz
    do you think 1% is good enough for RS-485 250k baud comms ?
    my instinct was no and at this point am not inclined to get into calibration schemes (how good do they get?)

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: How long does this take to execute

    With soft timing I mean anything that relies on counting instructioncycles for precise timing, like PAUSE, PAUSEUS, SERIN, PULSIN, etc. Same thing with the stuff that started this thread, we figured out a certain piece of code executes in x number of cycles but when there's an interrupt constantly "stealing" cycles away that timing is obviously no longer correct - nor constant.

    I can't say I understand why the uC must be a 5V one just because the bus is RS485 but the 18F25K22 is a very good choice, if it's got enough pins (otherwise the 45K22) or the 26/46 if you need even more FLASH.

    The choosen baudrate doesn't really matter when it comes to accuracy of the x-tal, if the clock is 1% off then the baudrate will be 1% off att 250baud and at 250kbaud. The internal oscillator is most likely fine but if you're designing a board and you can spare the pins I'd certainly design in the option to use a x-tal. (I'm using the 16F1519 in a project of mine, internal oscillator, on one board of 7 I had to tweak the baudcon register by two counts to get the correct baudrate since the internal oscillator was off. The other boards are spot on.)

    You say DMX tranceiver, are you going to receive data at 250kbaud as well? That will be "interesting"... :-)

    /Henrik,.

  3. #3
    Join Date
    Nov 2003
    Posts
    98


    Did you find this post helpful? Yes | No

    Default Re: How long does this take to execute

    "transceiver" is just the term for the driver chip, i only use in one direction
    there is an extension of the protocol that allows for a response from the light, i don't know how widely used that is or how much data traffic would be involved typically, my wild guess is little

    so i don't plan to support bi-directional and am aware it would be somewhere between challenging and impossible to do well
    nonetheless if the pins are available as an architectural thing i plan to allow movement in that direction in the future if it does not complicate the hardware overly

    re the the benefit of a 5V PIC, i am sure i could use a 3.3v part and a 5V transceiver (driver) chip and that they could play nice together but now the power system is maybe a bit more complicated

    initially i planned to let EVERYTHING run on LiPo voltage ranges 3.0- 4.2V
    the pots are ratiometric on the A/D, so that works fine
    but i have been advised not to run the RS-485 at 3..3V as it is not best practice
    do then i would need a DCDC converter for the driver chip
    with a 5V PIC i now have less different voltages to distribute, but i guess there will be a converter either way as i think about it (boost from LiPo to 5V)

    still 5V simplifies life as the wall wart can be 5V and override the LiPo
    getting a slick instant change over battery is going to be a challenge in itself, down time to charge is not acceptable, mechanically i would much rather have a buried one

    yeah, i realize 1% is 1% whatever the rate what really meant was whether 1% is good enough for professional comms ?
    googling around just now it seems that actually +-2% should be ok

    there is one more fly in this soup ...
    there may be i2c transmissions that need to be squeezed in somewhere, maybe 5 - 12 bytes worth (could be broken in half into two bursts)

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: How long does this take to execute

    Hi,
    It's certainly easier to have a single rail.

    I've actually never used I2C so my practical knowledege is very limitied but the manual says:
    The timing of the I2C instructions is set so that standard speed devices(100kHz) will be accessible at clock speeds up to 8MHz. Fast mode devices (400kHz) may be used up to 20MHz. If it is desired to access a standard speed device at above 8MHz, the following DEFINE should be added to the program:
    DEFINE I2C_SLOW 1
    It's a bit unclear what happens with the I2C clock at speeds over 20MHz, will it still be 100/400kHz?
    Since it's a synchronous protocol I would think it's not overly sensitive to the clock jitter caused by executing the command while the interrupt is active in the background but I don't know. On the other hand, 12bytes at 100kHz is about a 1ms. I guess you could squeeze that in between two DMX packets without too much impact on overall throughput.

    /Henrik.

  5. #5
    Join Date
    Aug 2011
    Posts
    453


    Did you find this post helpful? Yes | No

    Default Re: How long does this take to execute

    If you're the DMX transmitter then there's a lot of leeway in the timing. As long as you send a 512-byte packet once a second you're in spec. The time between bytes isn't really an issue either as long as you meet that. You'll probably want it faster than that, but there's usually plenty of time in your main loop to do stuff.

    Here's how I've done this in the past:
    - use two 512 byte packets... one for the main loop to fill (#1) and one for the ISR to transmit (#2).
    - in the main loop do whatever you need to create the DMX packet in buffer #1
    - copy the packet in buffer #1 to the second buffer #2 for the ISR to use to transmit
    - start the packet transmitting. after generating the BREAK/START timing, the ISR pulls bytes from the DMX transmit buffer #2 until done using the UART TXIF.

    The main loop can continue on generating the next packet since it uses buffer #1. Usually, things are so fast that the main loop ends up waiting for the DMX TX ISR to finish sending the previous packet before sending the new one since it takes at least 22ms for the ISR to send the 512 bytes.

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: How long does this take to execute

    I have a feeling that this project is on the limit of the 18F series chips with PBP.

    Eventually you may need to do a lot in assembly or finally select a 24F chip and C compiler...

    I really have not seen the spec's of the DMX512. Is it necessary to send data continually?

    Ioannis

  7. #7
    Join Date
    Aug 2011
    Posts
    453


    Did you find this post helpful? Yes | No

    Default Re: How long does this take to execute

    I have to admit I haven't done this using PBP, but I don't see any reason why an 18F25K22 @ 64MHz using DT-INTS wouldn't work out just fine.
    There's plenty of ram and speed available. For that matter, if you're just transmitting DMX you don't even need to use interrupts... they just make it easier to transmit one packet while generating the next one.

    DMX calls for a fixed baudrate of 250K with 8 bits of data + 2 stop bits, so that's 11 bits total (START + 8 data + 2 STOP) for 44us/byte. Note that if you're using a pic uart to send data you'll have to generate the second stop bit using a delay of 4us between bytes, but that's not normally a problem.

    DMX uses packets of 513 bytes (a START_CODE byte + 512 bytes of data). Normally packets are send continuously about 44 times/sec (22.7msecs) which is the max full-out time for 513 bytes, but as long as you send one packet every second that meets the spec. As the transmitter, there's no other byte-to-byte time limit so things are pretty flexible.

    If you're the receiver then things are a bit trickier since you HAVE to assume that you could get 513 bytes at the full-on speed of one byte/44us. That's still doable with a 25K22, but you almost have to use RX interrupts to collect a packet. That said, I've done both transmitters and receivers without using interrupts at all. Sometimes they just complicate things more than they help.
    Last edited by tumbleweed; - 18th August 2016 at 13:32.

  8. #8
    Join Date
    Aug 2011
    Posts
    453


    Did you find this post helpful? Yes | No

    Default Re: How long does this take to execute

    Oh, and somethings else I forgot to mention...

    DMX packets start with a BREAK signal, which is a low on the TXD pin of between 92-176us.

    For the transmitter I found it easier to generate the DMX BREAK signal using an extra IO pin.
    Put a 1-5K series resistor between the pic TX output and the 485 transceiver txd input pins, and tie the IO pin to that junction.
    Code:
    PIX TX out ---/\/\/\---------->RS485 TX IN
    IO pin     ____________|
    Normally, set the IO pin as an input so it's floating. When you want to generate the BREAK signal set it to output low
    for between 92us-176us and then make it an input again. You can also generate the BREAK timing by fidgeting around with the uart baudrate
    and transmitting a single 00 byte, but I found this to be a lot simpler.

Similar Threads

  1. Unable to execute mpasmwin
    By oldmainframer in forum General
    Replies: 3
    Last Post: - 17th December 2016, 23:01
  2. Interrupt won't execute.
    By bison_bloke in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 26th March 2010, 15:46
  3. Replies: 5
    Last Post: - 24th February 2009, 18:55
  4. Proteus Execute Error
    By pramarn in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th October 2006, 08:51
  5. SEROUT2 takes 1400ms to execute?
    By droptail in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th March 2006, 17:08

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts