Who furnished the device that Vader and Boba Fett use to torture Han Solo? Was it already in Cloud City for some reason, or was it brought in after the Millennium Falcon was tracked to Bespin?
The scan grid was normally used in the analysis of metals. A version of the system was also used on Bespin to detect the properties and purity of carbon-frozen blocks of Tibanna gas prior to further processing. The unfortunate Solo was soon to get a close look at the workings of this carbon-freezing process. In the main, however, the scan grid system was used to test the thermal and magnetic properties of metal samples.
Vader spent a short time altering it, removing the safeties and looping the electricals so that it continually emitted a (painful) scanning field.
With a few modifications, a Figg & Associates metallurgical scan grid became the focus of one of Captain Solo's really bad days.
DEADLY MODIFICATIONS: Normally, the scan grid would be lowered over a metal sample or plate. Vader had this procedure reversed, lowering a bound Han Solo into close proximity to the grid. The device was designed to analyse the structural and magnetic effects of a series of carefully controlled electrical discharges on the metal being tested. Imperial technicians bypassed safety cut-offs and the actual scanning routines of the system, sending the equipment into a loop that maintained the electrical surges at a high level and kept them running over and over again. The effect on Han was excruciating. It goes without saying that the members of the board of Figg & Associates were truly horrified when they heard the use to which Lord Vader had put their expensive equipment. They did not, however, choose to lodge a complaint.
MASTER OF PAIN: Darth Vader surpassed himself with the converted scan grid. Using only what he could find on a planet without military resources, the Dark Lord created an implement that the Emperor himself would have been proud of. The scan grid was inverted for its new application.
TORTURE: Han Solo had the dubious honour of being one of the few individuals in galactic history to have an implement of torture tailor-made for him. He was strapped in so that his agonized movements could not damage the precious device.
TRIALS: As Han Solo writhed in agony, Darth Vader relished the chance to witness the excellent performance of his masterful creation on its first and only field test.
Interestingly the (now non-canon) Junior Novelisation contradicts this by suggesting that the device was actually an Imperial torture device rather than something made from parts found at Cloud City. The "scan" part of the Scan Grid is a medical scanner used to ensure the victim stays awake.
Darth Vader watched as two stormtroopers prepared an elaborate mechanism in the prison entry area. The mechanism consisted of an adjustable rack that stood vertically and faced a slanted panel of assorted instruments, including chemical injectors, microsurgical vibroscalpels, diagnostic scanners, and an electroshock assembly. All the instruments were designed to induce pain, which was appropriate since the mechanism was engineered for torture.
Han Solo was strapped to the rack. Unable to move his arms or legs, he studied the pain-inducing instruments on the facing panel and tried to brace himself for the worst. From what he’d heard about Imperial torture devices, the diagnostic scanners would be used to anticipate loss of consciousness and the chemical injectors would keep him awake. That way, he wouldn’t pass out, and would experience every measure of pain.
In Legends, the device used to torture Han is a scan grid, a piece of mining equipment. Improvised torture methods are a mainstay of world history (see inventive things done with curling irons) so it's not surprising that that's true as well in the Star Wars universe.
The scan grid is mentioned in the Empire Strikes Back novelization. It's also mentioned in the fourth version of the ESB script:
LEIA I'm worried about all of us. I can't figure out what they're up to.
HAN Me either. They had me howling on the scan grid, but they never asked me any questions.